• 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

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

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Avneet Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
David Brossard
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
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

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:
 
Avneet Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all would appreciate more suggestions how to resolve this issue.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic