Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By Norm

Thread: Java Error

  1. #1
    VisualPK is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Java Error

    I'm trying to load a Web Client, but it says this error:


    Java Plug-in 1.6.0_31
    Using JRE version 1.6.0_31-b05 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Jerry and Christine
    ----------------------------------------------------
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------


    java.lang.UnsupportedClassVersionError: client : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.defineClassH elper(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.access$100(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknow n Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin2.applet.Plugin2ClassLoader.findClassHel per(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.UnsupportedClassVersionError: client : Unsupported major.minor version 51.0

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    VisualPK is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Java Error

    What it's supposed to do is download the cache, but the cache gets stuck at 0%, but here's the code.

    [7:11:14 PM] Austin:
    Java Code:
     import java.io.File;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.FileWriter;
    import java.io.BufferedWriter;
    import java.io.BufferedOutputStream;
    import java.io.BufferedInputStream;
    import java.io.FileOutputStream;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.net.URLConnection;
    import java.net.URL;
    import java.util.zip.ZipFile;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    import java.util.Enumeration;
    
    import sign.signlink;
    
    public class CacheDownloader {
    
     private client client;
    
     private final int BUFFER = 1024;
    
     private final int VERSION = 11; // Version of cache
     private String cacheLink = "http://dl.dropbox.com/u/51164319/cache.zip"; // Link to cache
    
     private String fileToExtract = getCacheDir() + getArchivedName();
    
     public CacheDownloader(client client) {
      this.client = client;
     }
    
     private void drawLoadingText(String text) {
      client.drawLoadingText(35, text);
      //System.out.println(text);
     }
    
    
     private void drawLoadingText(int amount, String text) {
      client.drawLoadingText(amount, text);
      //System.out.println(text);
     }
    
     private String getCacheDir() {
      return signlink.findcachedir();
     }
    
     private String getCacheLink() {
      return cacheLink;
     }
    
     private int getCacheVersion() {
      return VERSION;
     }
    
     public CacheDownloader downloadCache() {
      try {
      File location = new File(getCacheDir());
      File version = new File(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat");
      
      if(!location.exists()) {
       //drawLoadingText("Loading new Updates....");
       downloadFile(getCacheLink(), getArchivedName());
    
       unZip();
       //System.out.println("UNZIP");
    
       BufferedWriter versionFile = new BufferedWriter(new FileWriter(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat"));
       versionFile.close();
      } else {
       if(!version.exists()) {
        //drawLoadingText("Downloading Cache Please wait...");
        downloadFile(getCacheLink(), getArchivedName());
    
        unZip();
        //System.out.println("UNZIP");
    
        BufferedWriter versionFile = new BufferedWriter(new FileWriter(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat"));
        versionFile.close();
    
       } else {
        return null;
       }
      }
      } catch(Exception e) {
    
      }
      return null;
     }
     
     private void downloadFile(String adress, String localFileName) {
      OutputStream out = null;
      URLConnection conn;
      InputStream in = null;
      
      try {
    
       URL url = new URL(adress);
       out = new BufferedOutputStream(
        new FileOutputStream(getCacheDir() + "/" +localFileName)); 
    
       conn = url.openConnection();
       in = conn.getInputStream(); 
      
       byte[] data = new byte[BUFFER]; 
     
       int numRead;
       long numWritten = 0;
       int length = conn.getContentLength();
    
     
       while((numRead = in.read(data)) != -1) {
        out.write(data, 0, numRead);
        numWritten += numRead;
    
                   int percentage = (int)(((double)numWritten / (double)length) * 100D);
        drawLoadingText(percentage, "Downloading Cache " + percentage + "%");
    
       }
    
       System.out.println(localFileName + "\t" + numWritten);
       drawLoadingText("Finished downloading "+getArchivedName()+"!");
    
      } catch (Exception exception) {
       exception.printStackTrace();
      } finally {
       try {
        if (in != null) {
         in.close();
        }
        if (out != null) {
         out.close();
        }
       } catch (IOException ioe) {
       }
      }
    
     }
    
     private String getArchivedName() {
      int lastSlashIndex = getCacheLink().lastIndexOf('/');
      if (lastSlashIndex >= 0 
       && lastSlashIndex < getCacheLink().length() -1) { 
       return getCacheLink().substring(lastSlashIndex + 1);
      } else {
       //System.err.println("error retreiving archivaed name.");
      }
      return "";
     }
    
    
    
    
     private void unZip() {
    
      try {
           InputStream in = 
        new BufferedInputStream(new FileInputStream(fileToExtract));
       ZipInputStream zin = new ZipInputStream(in);
       ZipEntry e;
    
       while((e=zin.getNextEntry()) != null) {
    
                      if(e.isDirectory()) {
         (new File(getCacheDir() + e.getName())).mkdir();
                      } else {
    
        if (e.getName().equals(fileToExtract)) {
         unzip(zin, fileToExtract);
         break;
        }
                unzip(zin, getCacheDir() + e.getName());
        }
        //System.out.println("unzipping2 " + e.getName());
       }
       zin.close();
    
      } catch(Exception e) {
       e.printStackTrace();
      }
     }
    
     private void unzip(ZipInputStream zin, String s) 
      throws IOException {
    
      FileOutputStream out = new FileOutputStream(s);
      //System.out.println("unzipping " + s);
      byte [] b = new byte[BUFFER];
      int len = 0;
    
      while ((len = zin.read(b)) != -1) {
       out.write(b,0,len);
      }
      out.close();
     }
    }
    Last edited by Norm; 04-15-2012 at 03:25 AM. Reason: added code tags

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default Re: Java Error

    java.lang.UnsupportedClassVersionError: client : Unsupported major.minor version 51.0
    You compiled you code with java version 1.7 and tried to execute it with 1.6.
    Update the plugin to 1.7 or recompile to 1.6 version (javac has options to set version)
    Fubarable likes this.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    VisualPK is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Java Error

    Quote Originally Posted by Norm View Post
    You compiled you code with java version 1.7 and tried to execute it with 1.6.
    Update the plugin to 1.7 or recompile to 1.6 version (javac has options to set version)
    If we compile it with 1.6, will people with 1.7 be able to use the client?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default Re: Java Error

    Yes. Most newer JREs can execute older version classes
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    VisualPK is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Java Error

    Quote Originally Posted by Norm View Post
    Yes. Most newer JREs can execute older version classes
    We complied with JDK, not JRE. If that's relevant, just thought you should know. Does it make a different?

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java Error

    Quote Originally Posted by VisualPK View Post
    We complied with JDK, not JRE. If that's relevant, just thought you should know. Does it make a different?
    You can only compile with the JDK, not the JRE.

  9. #9
    VisualPK is offline Member
    Join Date
    Apr 2012
    Posts
    8
    Rep Power
    0

    Default Re: Java Error

    Quote Originally Posted by Fubarable View Post
    You can only compile with the JDK, not the JRE.
    I'm just talking for the coder now, so our best option to recompile with 1.6?

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default Re: Java Error

    The javac command has options to produce 1.6 output.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 16
    Last Post: 01-11-2012, 02:45 PM
  2. Replies: 0
    Last Post: 01-21-2011, 12:43 PM
  3. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  4. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  5. Replies: 1
    Last Post: 10-26-2009, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •