Unsupported major.minor version 49.0

Hello everyone, I am executing the next code...

import org.xml.sax.InputSource;

import javax.xml.xpath.*;

import org.apache.xpath.NodeSet;

public class peos {

public static void main(String[] args) {

try {

XPath xpath = XPathFactory.newInstance().newXPath();

String expression = "/widgets/widget";

InputSource inputSource = new InputSource("C:\\catalog.xml");

NodeSet nodes = (NodeSet) xpath.evaluate(expression, inputSource,XPathConstants.NODESET);

} catch (Exception e) {}

}

}

and i get this exception...

java.lang.UnsupportedClassVersionError: peos (Unsupported major.minor version 49.0)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:537)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)

at java.net.URLClassLoader.access$100(URLClassLoader.java:55)

at java.net.URLClassLoader$1.run(URLClassLoader.java:194)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:187)

at java.lang.ClassLoader.loadClass(ClassLoader.java:289)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)

at java.lang.ClassLoader.loadClass(ClassLoader.java:235)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

Exception in thread "main"

I am using jBuilder 2005 foundation and searching on the internet to find more about the problem I changed the default project properties at Build -> java : the language features to JAVA 2 SDK v.5.0, (generics enabled) and the Target VM to All java SDKs but still I couldnt make it work. Any suggestions ?

Thank you in advance

[1875 byte] By [flomastera] at [2007-10-2 20:09:56]
# 1

It sounds like you are trying to run Java 5 compliant byte code in a Java 1.4 VM. The 1.4 machine rejects the Java 5 code because it is too new and may not be compatible with the instructions that the 1.4 machine understands. You can lower your byte code version back to Java 1.4 (and lose the ability to use generics, etc.), or you can install a newer version of the Java virtual machine compatible with Java 5 or later.

Updownquarka at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
I found the problem. I had to change the JDK to version 5 at Default Project Properties -> Path -> JDK and not from the locations mentioned at the original post.
flomastera at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

The problem is due to for version 49.0 Jdk 1.5 or higher is required

First Check on command prompt with command to see which version JVM is using

java -version

see all path from java -verbose command

if it is showing wrong version then check the JAVA_HOME and path variables in Environment Variables.

if Paths there are correct then see any JRE path not comming before jdk path.

In my case Oracle JRE path was comming before jdk path and it was making all mess.

Hope this will help

Regards

Salman Zafar

Interconnect Billing Developer

S.Tech

Pakistan

Salman_Zafara at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 4
I can't see why Sun doesn't document this exception better in the API docs. Provide a mapping of the major/minor version numbers to the JREs required.
cknelsena at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 5

Solved

Just do these things.... If you initially complied your classes in jdk1.5 and if u r trying to run the same in 1.4.2 or other.. The already compiled classes will be expecting jdk 1.5 JRE for their runtime execution. So what u have to do is......

1.stop ur sever

2.delete the work directory in tomcat

3.Delete the work directory in your projects web-app Folder

4.Now cleann the project... Build... and Run Again ... . It should work...

if still it dont , i prefer use only jdk1.4.2 on system.. set enviorment variebles for it...Reinstall tomcat .. and do above mentioned steps ,,, This should solve the problem...

Message was edited by:

sunildm4u

sunildm4ua at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 6
> SolvedOh shut up, idiot. 5 of your 6 posts "solve" the same instances of a problem that were already solved months ago, and your posts usually don't even hit the topic as only one of the threads was about Tomcat. Stop bringing up zombies.
CeciNEstPasUnProgrammeura at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 7

Well I'm hoping someone can clear this up for me. I've read this topic and it seems like that should be it. However for me it's not.

I am running Java SE build 1.5.0-b64 (checked with the -version)

RMI Registry is the 1.5.0 JRE version

Using Eclipse 3.2 to run everything.

Compiled with JDK 1.5

And with all that I'm still getting the Unsupported major.minor version 49.0.

Any other thoughts would be helpful. Thanks

steve

DevKingdoma at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 8
Well I'm not sure what I did but I got it to work. I rebuilt the entire project after making the two RMI pieces (common and client) code compile in 1.4. The rest is compiled in 1.5. Now it seems to work over having it all in 1.5. Don't know whySteve
DevKingdoma at 2007-7-13 22:50:29 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...