Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtine Exception UnsupportedClassVersionError

 
Nilambari Brahma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed jdk1.6.0_17 successfully by setting path variable as %PATH%;.;C:\Program Files\Java\jdk1.6.0_17\bin
I have tested couple of java programs also. Today when I trying simple helloworld program , I am compiling it successfully but at the time of execution it's giving me exeption,



My program is,
class tester
{
public static void main(String [] ss)
{
System.out.println("Hello");
}
}


D:\JavaExamples>javac tester.java

D:\JavaExamples>java tester
Exception in thread "main" java.lang.UnsupportedClassVersionError: tester (Unsup
ported major.minor version 50.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)

D:\JavaExamples>set classpath=

D:\JavaExamples>java tester
Exception in thread "main" java.lang.UnsupportedClassVersionError: tester (Unsup
ported major.minor version 50.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)

D:\JavaExamples>javac -version
javac 1.6.0_17

D:\JavaExamples>java -version
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)

-------------------------------------------------------------------------------------------
I reinstalled jdk also. But is it because of some virus?
Kindly help me to sort this problem.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Append your newly installed java path in the beginning of the path variable in environment variables. Open a new command prompt & try again.

Say currently you have like this -> %PATH%;.;C:\Program Files\Java\jdk1.6.0_17\bin

Now change it to -> C:\Program Files\Java\jdk1.6.0_17\bin;%PATH%; (Idea is that your newly installed bin should be searched first for javac & java exes)

Thanks,
John
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That Exception means that the version of the javac tool you are using is newer than the version of the java tool. Try javac -version and java -version at the command line and see what happens.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have already used java -version. So you are running 1.4.2 somewhere? Have you got Oracle (the database) anywhere? That tends to install old versions of Java™. Otherwise there must be an old JRE in some installation folder; it is often installed automatically with Windows®.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, you should remove the . from your PATH.
 
Nilambari Brahma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right I have installed Oracle recenlty. But how can I now change my runtime environment to 1.6?
I removed . from path
 
Nilambari Brahma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I could change now the runtime environment. But now it gives NoClassDefinationFoundError.
Please help.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure the class file is present in the directory path pointed by the cmd prompt? Are you trying to compile the tester program you mentioned above?

This might help - NoClassDefFound - Ranch older thread
 
Nilambari Brahma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you folks. It works. While testing it all i had set classpath to bin directory of jdk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic