File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Runtine Exception UnsupportedClassVersionError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Runtine Exception UnsupportedClassVersionError" Watch "Runtine Exception UnsupportedClassVersionError" New topic
Author

Runtine Exception UnsupportedClassVersionError

Nilambari Brahma
Greenhorn

Joined: Apr 14, 2011
Posts: 6
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
Bartender

Joined: May 31, 2011
Posts: 1776
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

Joined: Oct 13, 2005
Posts: 40052
    
  28
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

Joined: Oct 13, 2005
Posts: 40052
    
  28
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

Joined: Oct 13, 2005
Posts: 40052
    
  28
By the way, you should remove the . from your PATH.
Nilambari Brahma
Greenhorn

Joined: Apr 14, 2011
Posts: 6
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

Joined: Apr 14, 2011
Posts: 6
Hi
I could change now the runtime environment. But now it gives NoClassDefinationFoundError.
Please help.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
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

Joined: Apr 14, 2011
Posts: 6
thank you folks. It works. While testing it all i had set classpath to bin directory of jdk
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtine Exception UnsupportedClassVersionError