File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception in thread "main"" Watch "Exception in thread "main"" New topic

Exception in thread "main"

ShivKumar Rajawat

Joined: Mar 13, 2007
Posts: 17
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 Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at 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

Regards<br />-Shiv
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

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).

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Urs Waefler
Ranch Hand

Joined: Mar 13, 2007
Posts: 77

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

SCJP 1.4
ShivKumar Rajawat

Joined: Mar 13, 2007
Posts: 17
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/

even then the same error persists.

who told me to be a software engineer!!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
ShivKumar Rajawat

Joined: Mar 13, 2007
Posts: 17
Thanks Jesper,
you are right. i have Oracle Jinitiater in my system that is causing this problem.

thanks a lot guys ..
I agree. Here's the link:
subject: Exception in thread "main"
jQuery in Action, 3rd edition