Forums Register Login
Exception in thread "main"
Hi everybody
I am trying to run a small program on a new "Windows XP" system. i am using jdk 1.5.0. it's the same old "hello world" program. it compiles without any errors or warnings , but when i try to run this program it displays this exception :

Exception in thread "main" java.lang.UnsupportedClassVersionError: hi (Unsupport
ed 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)

the class code is :

public class hi
public static void main (String [] args)

can somebody please explain what may be causing this exception
Looks like you are compiling your code with JDK 1.5.0 but trying to run it with a 1.4 JRE. If you have both installed make sure you are using the version of Java you thing you are (try java -version fro mthe command line).

Always when I see such messages, I have a look at the Java API. There is a Class UnsupportedClassVersionError. Me too, I do not understand at the moment. I only know it is an Error.

Further one can read in the API: Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.

Best Regards
Thanks Paul and Urs,
I checked the version of java. this is ""

D:\>java -version
java version ""
Java(TM) 2 Runtime Environment, Standard Edition (build
Java HotSpot(TM) Client VM (build 1.3.1-rc2-b22, mixed mode)

then recomplied the class with
D:\>javac -source 1.3 shiv/hi.java

even then the same error persists.

who told me to be a software engineer!!
Why do you have Java 1.3.1 on your system? Uninstall that old version.

Do you have Oracle software on your system? Oracle has the bad habit of supplying a Java 1.3 JRE with their software.

Check your PATH setting and make sure that your Java 5 JRE is in the PATH correctly. Remove the Java 1.3 JRE from the PATH.
Thanks Jesper,
you are right. i have Oracle Jinitiater in my system that is causing this problem.

thanks a lot guys ..
Pay attention! Tiny ad!
Thread Boost - a very different sort of advertising

This thread has been viewed 855 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 23, 2018 15:33:30.