aspose file tools*
The moose likes Beginning Java and the fly likes getting Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting Exception in thread "main" java lang Unsupported Class Version Error" Watch "getting Exception in thread "main" java lang Unsupported Class Version Error" New topic
Author

getting Exception in thread "main" java lang Unsupported Class Version Error

Avneet Singh
Ranch Hand

Joined: Apr 25, 2006
Posts: 51
Hi all im gettin an error on running a code, i ws doin java ntwk tried to run it and i got

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

so i decided to make a simplest java code which prints hello world
below is that code -
class HELLO
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}


and it gave the same error above.
All help would be appreciated thanks.


thanks
Avneet
David Brossard
Ranch Hand

Joined: Jun 03, 2004
Posts: 109
That's because you're using classes compiled with different versions of Java.

Typically if you use a j1.5 compiled class in a J1.4 JVM, it's not going to work.


No matter what they say in Ohio, we're still first in flight!
Avneet Singh
Ranch Hand

Joined: Apr 25, 2006
Posts: 51
hi
well i have jdk1.5 and no other version of java is installed on my system.
I have checked that, can there be any other reason .
Avneet Singh
Ranch Hand

Joined: Apr 25, 2006
Posts: 51
ur rt i cudnt find any other java installation but ya
java -version and javac -version give different version.
its 1.3 and 1.5

thanks man
avneet
Avneet Singh
Ranch Hand

Joined: Apr 25, 2006
Posts: 51
david any suggestions wud be appreciated
there is one jdk folder in ora92 that is oracle directory.
shud i go ahead and delete that.
i also found java in windows/system32 wht shud i do about that.
or any way i can resolve this issue

waiting for reply
thanks
avneet
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Avneet Singh:
ur rt i cudnt find any other java installation but ya


For goodness' sake - does your keyboard have no vowels?! Please use real words!


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

There are lots of choices; I'll list them in my personal order of preference.

If there's no other version of Java listed in your Control Panel "Add/Remove Software" page, you could simply delete the java.exe in system32. You might keep a copy of it somewhere just in case you find something breaks and you need to put it back.

You could change your PATH to put Jdk1.5\bin in front of Windows\system32.

You could start Java programs from a batch file which set the PATH to put jdk1.5 first.

You could always start Java by typing the full path.


[Jess in Action][AskingGoodQuestions]
David Brossard
Ranch Hand

Joined: Jun 03, 2004
Posts: 109
I personnally removed the java in windir\system32 which in turn broke my eclipse install because my java_home is not in my environment variables.

So what I then did is change the way I start Eclipse so that it first sets a temporary environment variable and path containing the path to java.

I did this because at some point I was trying stuff with J1.4 and 1.5 and eventually got the error you have.

Nowadays my system (windows) knows nothing about java. When I run stuff, I just go into a dos prompt and run a batch I wrote:

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14433
    
  23

Originally posted by Avneet Singh:
david any suggestions wud be appreciated
there is one jdk folder in ora92 that is oracle directory.
shud i go ahead and delete that.
i also found java in windows/system32 wht shud i do about that.
or any way i can resolve this issue

waiting for reply
thanks
avneet

Maybe you should not delete the JDK in the Oracle directory, but you should definitely remove it from the PATH environment variable.

Oracle has the bad habit of installing a JDK that you don't want... :roll:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Avneet Singh
Ranch Hand

Joined: Apr 25, 2006
Posts: 51
well i have set java home variable and in my env variables there is no mention of jdk 1.3
i tried the batch file thing but running that also doesnt make a diff.
the one system32 i replaced it with the latest java 1.5 .

any more suggestions.

thanks avneet
Avneet Singh
Ranch Hand

Joined: Apr 25, 2006
Posts: 51
Hi all would appreciate more suggestions how to resolve this issue.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

There's no way that the batch file solution, properly executed, would not work. Likewise, replacing all old java.exe files with new 1.5 ones would also work with 100% certainty. We really can't give you any more suggestions -- you just have to follow the ones we've already given.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting Exception in thread "main" java lang Unsupported Class Version Error