• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread "main"

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
this is supposed to be a surprise, but it smells like a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic