Results 1 to 10 of 10
  1. #1
    jobud9 is offline Member
    Join Date
    Dec 2011
    Posts
    34
    Rep Power
    0

    Default java applet error

    i'm getting an error when I run my applet.
    my error:
    Java Code:
    java.lang.UnsupportedClassVersionError: applet : 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(Unknown Source)
    	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.UnsupportedClassVersionError: applet : Unsupported major.minor version 51.0
    my source code:
    Java Code:
    import javax.swing.JApplet;
    import javax.swing.SwingUtilities;
    import javax.swing.JLabel;
    
    public class AppletMain extends JApplet {
        public void init() {
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        JLabel lbl = new JLabel("Hello World");
                        add(lbl);
                    }
                });
            } catch (Exception e) {
                System.err.println("createGUI didn't complete successfully");
            }
        }
    }

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java applet error

    java.lang.UnsupportedClassVersionError: applet : Unsupported major.minor version 51.0
    This error message arises when you try to run an applet with a Java runtime that is older than the version you compiled with. In this case you used a JDK 1.7.x to compile with, but your runtime is 1.6.* or less.

    You can get the compiler to produce byte code that will run on a specified (or later) runtime by using the -target option. See the javac man page. IDEs allow you to control analogous things through something they will often refer to as "project settings" or similar.

  3. #3
    jobud9 is offline Member
    Join Date
    Dec 2011
    Posts
    34
    Rep Power
    0

    Default Re: java applet error

    I tried compiling it in several different versions, but i'm still getting the same error. is there another reason i'm getting this error?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: java applet error

    is there another reason i'm getting this error?
    No, there isn't.

    It's possible you're not running the latest compile. Delete the .class file(s) before recompiling.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java applet error

    And web browsers can very "helpfully" not realise that your applet has changed. Try testing things with appletviewer. (I haven't checked, but I am assuming this is still part of the jdk.)

  6. #6
    jobud9 is offline Member
    Join Date
    Dec 2011
    Posts
    34
    Rep Power
    0

    Default Re: java applet error

    it says unsupported version major.minor 51.0.. i'm assuming this is not the JRE or compiler version? I have re-installed my Google JRE but it had no effect on the applet. I'm running JDK 7 and I think my browser is running a JRE version of 6. Might a version conflict between my browser and PC be causing this error?

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: java applet error

    Might a version conflict between my browser and PC be causing this error?
    Yes, that is exactly what is causing the error.

    See reply #2 for what you do about this. (Or check for an updated java runtime and adjust your browser to use it.)

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: java applet error

    Quote Originally Posted by jobud9 View Post
    I have re-installed my Google JRE
    What's that?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    jobud9 is offline Member
    Join Date
    Dec 2011
    Posts
    34
    Rep Power
    0

    Default Re: java applet error

    okay well I re-compiled the class files in a java 6 JDK and I am no longer getting this error. but now it the applet freezes up. I have both JRE 6 and 7. would that be the problem

  10. #10
    jobud9 is offline Member
    Join Date
    Dec 2011
    Posts
    34
    Rep Power
    0

    Default Re: java applet error

    @db
    my Google chrome JRE? it's chromium's java plugin.

Similar Threads

  1. Certification Error on Java Applet
    By netsuvi in forum Java Applets
    Replies: 0
    Last Post: 06-21-2011, 10:16 AM
  2. Replies: 1
    Last Post: 05-17-2011, 08:05 PM
  3. Java Applet Error at Eclipse on Linux Ubuntu
    By bytescode in forum Java Applets
    Replies: 2
    Last Post: 01-31-2011, 09:49 AM
  4. Java Applet Runtime error
    By sarwar1234 in forum Java Applets
    Replies: 12
    Last Post: 09-21-2010, 02:26 PM
  5. Basic Java applet error, cant figure it out!
    By alacn in forum Java Applets
    Replies: 3
    Last Post: 08-03-2010, 06:25 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
  •