(Unsupported major.minor version 49.0)

I'm very very new to Java and have created a quick application using NetBeans 5.0 under Windows XP

The only JDK I've got installed is: J2SE Version 5.0 Update 6.

When I check for the J2SE runtime Environment, it shows that I have Version 5, Updates 1 through 7 installed.

I've built my application and the relevant files appear to exist, however dropping to a command line and running :

//////////////
java -jar "D:\java_projects\ContactEditor\dist\ContactEditor.jar"
/////////////

Gets the following error:

//////////////
Exception in thread "main" java.lang.UnsupportedClassVersionError: my/contactedi
tor/ContactEditorUI (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)
//////////////

When I check to see what version of Java I have available with a "java -version" I get the following:

//////////////
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
//////////////

I'm confused as to how to "execute" the .jar file using a 1.5 JRE....

Any ideas on where I'm going wrong? The project works great within the IDE...

misdevelopmentAsked:
Who is Participating?
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
Set JAVA_HOME environment variable to refer to your JDK 1.5.06 installation root JDK directory.

Ensure that %JAVA_HOME%\bin is there in the path followed by everything else separated by semi-colon ;
0
 
Mayank SAssociate Director - Product EngineeringCommented:
(Assuming that is the version to which your Netbeans project is referring).
0
 
Mayank SAssociate Director - Product EngineeringCommented:
If you don't know how to change environment variables, goto My Computer, right-click -> Properties -> Advanced -> Environment variables (add a new System environment variable for JAVA_HOME if it is not present).

Also verify in the registry -> HKEY_LOCAL_MACHINE -> SOFTWARE -> JavaSoft -> Java Runtime Environment -> CurrentVersion as to what the current version is.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
hoomanvCommented:
as a highlight
49 means that it was compiled with a 1.5, and 48 means 1.4. Depending on how it was compiled it may not be usable on 1.4. The 1.5 defaults to writing class files that are only compatible with 1.5
here you can learn more abour major/minor versions
http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html
0
 
misdevelopmentAuthor Commented:
All environment variables have been added and checked. The current version within the Registry shows as 1.5

Still getting the same error messages...... Java -version is still showing 1.3.

Tried the obvious reboot after the changes to no avail....

Quite bizarre... :-)

JC
0
 
misdevelopmentAuthor Commented:
Having investigated further than the end of my nose and decided to search for how many versions of java.exe I'd got on my system, it turns out my Oracle client has a java.exe and Oracle appears first on my PATH statement!

Running the java.exe from within the directory that I wanted to be in worked perfectly....So, just down to paths / variables !!!

Thanks all!
0
 
JavatmCommented:
The best solution is to uninstall every java vm's you might have then install the latest version which is 1.5 this will not work unless your not the admin.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> it turns out my Oracle client has a java.exe and Oracle appears first on my PATH statement

Yes, it will - which is why I told you to define JAVA_HOME and put %JAVA_HOME%\bin in the PATH before everything else so that this version of Java is the default one.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.