Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

UnsupportedClassVersionError, help

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I installed the jdk 5(jdk-1_5_0_08-windows-i586-p) in my computer and set
the path variable to the bin directory and class path to MyProgram. Then I wrote a small Hello program and compiled. Compilation was successful but when I tried to run the program,I got the following :

C:\MyProgram>java MyClass
Exception in thread "main" java.lang.UnsupportedClassVersionError: MyClass (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:11
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)

C:\MyProgram>

My Hello world program is as follow:

public class MyClass{
public static void main(String[] args){
System.out.println("Hello World");
}
}

I don't get any error when I use jdk1.4. can someone tell me why ?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Did you remove the reference for your installed jdk1.4/bin from your path after modifying it to jdk1.5 ??
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I think your class is compiled correctly with 1.5 but its trying to run using 1.4 version. use java -version to see the java version you are dealing with and also try removing all other references(paths and classpaths) in the environment variables when you are using a particular version. Also check both your user and system paths in the environment variables.
 
Key Young
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thank you Praveen and Joy. I think Praveen you are right.
The only path value I have in the environment variable is version 1.5
However when I do java -version , I get version 1.3. And there is no jdk 1.3 installed in my machine at all. Anybody know how to fix it.
Please help it is very frustrated.
 
Ranch Hand
Posts: 257
Hibernate Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello,

You are trying to run the class file with 1.4 version, which is being generated by 1.5 version JAVA compiler. Check your PATH variable whether it is pointing to JVM of 1.4 or 1.5.
 
Key Young
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Srinivas. Like I said in the previous post the only path value I
have is for jdk 1.5.
But this is not the most inexplicable thing I found out. My friend's
computer has only path value for version 1.4, but when I tried
java -version on his computer I got version 1.5.

The OS in my PC still see version 1.3 for some reason.
Can someone out there please lend a helping hand because this is really
annoying.
 
Joy Mookerji
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Whats the value of JAVA_HOME is it defined .......
do like this and test

define
JAVA_HOME=C:\jdk1.5 (environment variable)

Try to run it.......

define CLASSPATH environment variable

to some thing like this
C:\jdk150_04\lib\tools.jar;C:\jdk150_04\jre\lib\rt.jar
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This seems to have been superceded by a new topic on the same issue...
Closing.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    Bookmark Topic Watch Topic
  • New Topic