Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while migrating from jdk1.3 to jdk1.5

 
Preethinj Math
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am migrating from sdk1.3 to jdk1.5, and when I comile a program
it comiled fine,but when I tried to run that program,I got an error message saying that

Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown 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.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 java.lang.ClassLoader.loadClassInternal(Unknown Source)


I didn't understand what to do next,I changed in classpath,path everywhere from 1.3 to 1.5.
Need advice!

Thanks
 
Henry Wong
author
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you get when you run "java -version" ?

Henry
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have attempted to load a class running under a VM that does not support that version of the class file. For example, you have (probably) compiled with -target 1.5 on a 1.5 compiler and are now trying to run it on a 1.3 VM.

The API spec. for that specific exception will likely yield more results.
 
Preethinj Math
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
when I ran with the command :java -version helloworld
I got this message as

java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

looking for some help!
thanks,
 
Henry Wong
author
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be migrating from Java 1.3 to Java 1.5, but for some reason, your "java" interpreter is from Java 1.4.2. You need to configure your system to use the "java" that came with 1.5, assuming that is what compiler you used.

Henry
 
Preethinj Math
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry,

now I have another question.
How do I configure my system to use the "java" that came with 1.5,?
I have no idea.

Thank again
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to make sure that your PATH environment variable points to the location of your 1.5 SDK bin directory. Therefore you need to remove the 1.4 jdk from the path and add the 1.5

i.e on my machine the PATH is

PATH=C:\progra~1\java\JDK15~1.0_0\bin;.....



You might also want to make sure that your CLASSPATH variable doesn't point to any old classes.
 
Rachil Chandran
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also if u have both the paths, for the 1.5 and 1.4.2 in ur path variable, the path that is specified first (from left to right ofcourse) would be take.
eg: path=~/1.5/bin;~/1.4.2/bin; would use your 1.5 version every time you execute java command
 
Preethinj Math
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally it worked! thanks a lot

I had jdk1.5 only in the path but before that there was a oracle path with 1.4.2 and may it was going there and picking that one,when I moved the jdk1.5 to in the beginning it worked fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic