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: HELP ME!!- Starting to use java and problems with that damned jdk-

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default HELP ME!!- Starting to use java and problems with that damned jdk-

    Hello folks, I am completely new to java and I don't know anything about programming.
    I have started with the application "HelloWorldApp" and I have bypassed the problem that javac was not a recognized command.
    Now I have HelloWorld App.class, but when I try to run it on the prompt it says:

    C:\Users\Acer\Desktop>java HelloWorldApp
    Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorldApp
    : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    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.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unkno wn Source)

    I have on my pc both jdk1.8.0 and jdk1.7.0. I changed the classhpath on the control panel to both jdk1.7.0 and 1.8.0 but the problem continues. I run windows 7, 64 bit system. Please help me.

    Alex


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: HELP ME!!- Starting to use java and problems with that damned jdk-

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    I've never seen your error before, so I Googled it and found this. It might not fit your problem exactly, so you should continue looking until you find a path to fix your specific problem that you think will work.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: HELP ME!!- Starting to use java and problems with that damned jdk-

    java.lang.UnsupportedClassVersionError: HelloWorldApp
    : Unsupported major.minor version 52.0
    The class file was created with a younger version of java than the jre being used to execute it. Change one or the other to get them the same or have the jre be the younger.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: HELP ME!!- Starting to use java and problems with that damned jdk-

    Quote Originally Posted by Blackberry 101 View Post
    C:\Users\Acer\Desktop>java HelloWorldApp
    Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorldApp
    : Unsupported major.minor version 52.0
    Norm's right that the class file was created using a younger version (i.e., released more recently) of Java than the JRE that is being used to execute it. More precisely, "version 52.0" refers to Java 8, i.e., the Java source file was compiled using JDK 8 (1.8). (See Java class file - Wikipedia, the free encyclopedia under the "General layout" section, for byte offsets 6 and 7.) When you ran "java HelloWorldApp", "java" must have been referring to Java 7's java.exe, hence the mismatch.

    The most direct way to fix this is to uninstall Java 7. If for whatever reason this is not an option, and since as quoted above you're executing the class file via command line by running "java" directly, then you'll need to change Windows' PATH environment variable. See PATH and CLASSPATH (The Java™ Tutorials > Essential Classes > The Platform Environment).

    Take care to check that your PATH environment variable does not contain paths to both Java 7's and Java 8's "bin" folder. It should contain the path to just 1 version so that when you run "javac" and "java", they both use the corresponding .exe files from the same JDK version.

  5. The Following User Says Thank You to jashburn For This Useful Post:

    Blackberry 101 (May 11th, 2014)

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: HELP ME!!- Starting to use java and problems with that damned jdk-

    The java.exe file can also be here:
    C:\Windows\System32\java.exe

    That's another consideration when looking at the PATH variable.
    Some java installs copy it there.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #6
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: HELP ME!!- Starting to use java and problems with that damned jdk-

    Thank so much guys, I've been busy and I haven't had the time to try.
    I will check it now and let you know.
    Yes, I have done a mess with the two version of jdk installed.

    --- Update ---

    Yeah, it worked.
    It was a problem of jdk versions against each other.
    I just uninstalled jdk 7 and set the variable path to the latest version and it worked.
    Thanks a lot to everybody and good luck.

Similar Threads

  1. }Eclipse{____How to add java src code______}Java 7 JDK{
    By ClarmonkGaming in forum Java IDEs
    Replies: 1
    Last Post: February 27th, 2014, 04:44 AM
  2. JDK 1.7 migration issue: java.lang.ExceptionInInitializerError
    By raghavanak in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 16th, 2014, 03:23 AM
  3. Starting with Java
    By corbs in forum Java Theory & Questions
    Replies: 4
    Last Post: March 29th, 2013, 01:20 PM
  4. Need help starting on Java
    By dfixx in forum Member Introductions
    Replies: 2
    Last Post: November 18th, 2012, 04:12 AM
  5. Help with jdk/Java software
    By IpodHero in forum Java IDEs
    Replies: 1
    Last Post: December 16th, 2010, 11:05 AM

Tags for this Thread