• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main"

 
ShivKumar Rajawat
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
{
System.out.println("hi");
}
}


can somebody please explain what may be causing this exception
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Urs Waefler
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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
Urs
 
ShivKumar Rajawat
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul and Urs,
I checked the version of java. this is "1.3.1.9"

D:\>java -version
java version "1.3.1.9"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1.9)
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!!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ShivKumar Rajawat
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper,
you are right. i have Oracle Jinitiater in my system that is causing this problem.

thanks a lot guys ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic