Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Version issue? Or what else can it be?

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Version issue? Or what else can it be?

    Hi All,

    I'm new to Java and am still confused by many things.

    Let me first state the problem that I want to solve: I have an application that is made to work as a bunch of web pages generated locally according to user's input and using Javascript. The missing element is access to SQL (MS SQL Server 7.0, in my case). After a lot of browsing, I concluded that, with Firefox as browser, my only way to access the DB locally (without a running web server) would be through a Java applet.

    I got inspiration from the web, created an applet, installed the latest JDK, and failed to run. The error message looks like this:

    Java Plug-in 1.6.0_26
    Using JRE version 1.6.0_26-b03 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Timisoara
    ----------------------------------------------------
    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: HelloWorld : 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 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: HelloWorld : Unsupported major.minor version 51.0


    I kept searching the web, concluded that I'm trying to see a 1.7 binary code with a 1.6 able browser, and looked for alternatives.

    In my search, I stumbled over this "Hello World" applet. And now comes the puzzling part: if I try to run the example from their web site, it works. If I download the .class and .html files provided, and run them locally (same browser), I end up with the same error message.

    What's the explanation? How can I go over this error?

    Thanks,
    SxN


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Version issue? Or what else can it be?

    20 views, not one suggestion... is it so weird? Is there, perhaps, a work around?

    (biting nails)

    Thanks,
    SxN

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Version issue? Or what else can it be?

    The class version exception indicates the code was compiled with a JDK that is later than the JRE running said code. The target versions can be set when compiling, to allow earlier versions of the JRE to run the code (assuming the code is compatible with those versions). The browser showing different results online vs. locally suggests perhaps 2 jre versions, each run in the different environment, but I won't speculate as to why.

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Version issue? Or what else can it be?

    Thanks for you reply.

    I suspected that is a version issue. I tried compiling with -target 1.6, and the compilation failed with:
    javac: target release 1.6 conflicts with default source release 1.7. I got the same error with target 1.5.

    The next step was to install all JRE and JDK versions available, which made JRE unavailable for FireFox too. After that, I reinstalled the JDK (which will install the JRE as well). When I attempted to use my test class, FireFox asked to update its plugin, and afterward failed in the same way.

    I tried to use online compilers and I forced version 1.6, then 1.5 - nothing helped.

    I tried the simple example "Hello world" mentioned in my first post, and, as I mentioned, the online execution works, the local one fails.

    What are my options?
    Thanks,
    SxN

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Version issue? Or what else can it be?

    Hello again,

    I (kind of) solved my problem. Found an old W2K box, with an old Java compiler (1.4.2_80), and used that. It compiles and runs on the old machine, it runs on the new one too.

    Well, time to move on.

    Regards,
    SxN

  6. #6
    Member
    Join Date
    Oct 2011
    Posts
    42
    My Mood
    Sneaky
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Version issue? Or what else can it be?

    If you download an earlier version of the JDK (The same as your JRE) you won't need to use a workaround, have a look at: Java SE JDK 6u25 Download

Similar Threads

  1. Loading different version of jar lib from servlet
    By testxyz in forum Java Servlet
    Replies: 2
    Last Post: November 2nd, 2011, 10:53 AM
  2. jre version in command line
    By major in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 14th, 2011, 06:55 AM
  3. Need to uninstall the previous version of java?
    By akanksha4000 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 25th, 2011, 09:40 AM
  4. MarshallableObject for java 6 version
    By AllenK in forum Java SE APIs
    Replies: 12
    Last Post: July 5th, 2010, 02:51 AM
  5. Replies: 5
    Last Post: April 20th, 2009, 06:47 AM