• 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

Unsupported major.minor version 50.0

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I developed and tested my java classes in my laptop, and it works fine. As soon as I moved to another machine, I faced these errors:

This is the JDK configuration in both machines :
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)


Regards,



[ March 06, 2008: Message edited by: David O'Meara ]
 
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The message about version 50.0 means that the class files were compiled for JDK 1.6 (or greater, when others are released). The JVM that's reading that file must not be 1.6. How exactly are you starting the program on the second machine? I think you're somehow getting a different JVM than you expect.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your quick reply,

I checked again, and both of my machines have the same JDK



The only different between these two is when I create a new java project in Eclipse, in my laptop (working machine) I have jre.1.5.0_06 in the project libraries, but it's j2sdk1.4.2_04 in the second machine( not working one).

About running my code, I use ANT to pass some arguments and then run my classes. It's the same situation for both computers.
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you getting the version infomation - by typing java -version at the command line? Running java through ant may give you a different result. How is your JAVA_HOME environment variable set? Make sure it points to your JDK 1.6 directory.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and repeat the exercise with javac -version just in case the java -version is picking up a JRE rather than a JDK.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you think it might be the problematic thing?

The problem is, in the working machine, it's lower than 1.6, but in the one that is not working is 1.6. I think it should run this code as it's been compiled and run in older versions of JDK before.

The most important thing is I created a new java project in the new machine and set all jdk. I re-compiled my code, but still it's not working.

In my laptop (working machine)
///////////////////////////
JAVA_HOME -> jdk1.5.0_06
///////////////////////////
javac 1.5.0_06
///////////////////////////
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
---------------------------------------------------------------------

In another machine ( not working)
//////////////////////////
JAVA_HOME -> JDK 6
//////////////////////////
javac 1.6.0_03
//////////////////////////
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paradiso Noir:
Do you think it might be the problematic thing?



Yes, I recognize the error message, and it's definitely what you would see if the class file was compiled with JDK 1.6 but the JVM is 1.5 or less. I realize your command line is telling you that the second machine has JDK 1.6, but again, when you run java through Ant you may be using a different JDK. You need to check the value of your JAVA_HOME environment variable. If you don't have one, set one - Ant will use it to find the correct JDK.

Another thing to try is to compile and run the following simple program - in Ant:

The point is to verify which JDK is being used when you run java in Ant, the same way that the failing program is being run.
[ March 06, 2008: Message edited by: Mike Simmons ]
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to run that code inside an ant. It gave me the same error of "(Unsupported major.minor version 50.0)", and it does not even show me the code.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I removed the 'Urgent' from the title. It won't make people come any faster, and many consider it rude.

This is why we ask people to EaseUp.

Good luck with your problem.
Dave
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so compile it using -source 1.5 and -target 1.5. Or use 1.4 or even 1.3. You can do this in Ant using

You haven't said anything about the JAVA_HOME environment variable. That's probably going to be the key to fixing this, so it would be a good idea to find out what it is.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Mike for your quick responses.

First machine (Working) : JAVA_HOME -> jdk1.5.0_06
Second machine(Not working) :JAVA_HOME -> JDK 6

That does not make any sense for me as the second computer has a higher JDK that can support lower ones as well.

I will try what you said and get back to you as soon as possible.

Regards,
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did the source and target in JAVAC of my ant file, and still it's not working
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's very weird. What if you just compile it from the command line:

Then try running the class file from Ant. (You may have to move it to your class folder, or wherever you put executables.) Does it still complain about version 50.0, or is it a different number now?
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike,
First of all, thanks for your wonderful contribution to the community. Step by step the problem is solving, and during that time, I found you're such a helpful person. Honestly, I do appreciate that.

OK, After I compiled my test class, and then run it using my ant. It starts working. I have to do the same things with my other classes.

There is an important question. As Ant uses the same JAVA_HOME in any computer to point to a JDK. Why it does run based on another JDK? why not use the default one?

I don't know if I asked my question clear or not ?

Thanks
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paradiso Noir:
OK, After I compiled my test class, and then run it using my ant. It starts working. I have to do the same things with my other classes.



And what did it tell you? What JDK was Ant using on the second machine?

Originally posted by Paradiso Noir:
There is an important question. As Ant uses the same JAVA_HOME in any computer to point to a JDK. Why it does run based on another JDK? why not use the default one?



I'm not sure. But I think that the idea of a default JDK is a bit complicated. It depends on the PATH, which is used by many different applications on your computer, not just Java applications, and so it has many different things in it. The PATH contains a list of different locations which must be searched for executable programs whenever you invoke a command from a shell. And what if you have a JRE 1.5 in your PATH, ahead of a 1.6 JDK? It's possible that the java and javac commands use different versions. What is the default JDK in this case? The PATH can get to be quite a mess since it's shared by many different applications.

I think if I had been creating something like Ant, or Tomcat, I would probably find it simpler to have a single defined location for the JDK. It's just one directory (with subdirectories), and everything you need is in there. There may be other JDKs on the machine, but the one that JAVA_HOME points to is the one that we're using. I'm not sure which application originally defined JAVA_HOME and started using it (Tomcat was where I first heard of it, before Ant) but now it's a convention used by many Java applications. I think it's just simpler than searching the whole PATH for things. Maybe there are other reasons why it's used, that I haven't thought of.
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prior use of ant, you have to configure your JAVA_HOME to an appropriate JDK.

I have a new error as the number is changed from 50 to 49:

java.lang.UnsupportedClassVersionError Unsupported major.minor version 49.0)
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's quite ironic at some point.

When I compile them, they give me a different error.

I don't know why the class in which rose an exception are different as source/target changes?

if -source 1.4 -target 1.4

java.lang.UnsupportedClassVersionError: javax/jms/Destination (Unsup
ported major.minor version 49.0)

if -source 1.4 -target 1.5
java.lang.UnsupportedClassVersionError: myclass (Unsupported major.minor version 49.0)

if -source 1.5 -target 1.6

java.lang.UnsupportedClassVersionError: myClass (Unsupported major.minor version 50.0)
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(written before I saw the last post)

Version 49.0 means the file was compiled for JDK 1.5, and the JVM isn't familiar with 1.5. Try compiling for version 1.4 or 1.3. Or even 1.2 or 1.1 if problems persist. At some point, you should be able to find a version that works. (If it's version 1.0, just shoot yourself now.) That won't answer the question of why you're getting this old version of the JVM, but at least it will give some more information.

If you look at the API for System.getProperties(), it has a list of standard properties you can access. Once you have a version of Test.java that can compile and run, try adding some more of those properties, especially the ones beginning with java, like java.home, java.vendor and java.vm.vendor. One of these may give a clue about where it's finding this extra JVM that Ant is somehow running. I would just print out all of the java.* properties to see what they tell you.
[ March 07, 2008: Message edited by: Mike Simmons ]
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paradiso Noir:
if -source 1.4 -target 1.4

java.lang.UnsupportedClassVersionError: javax/jms/Destination (Unsup
ported major.minor version 49.0)



OK, this is different. The class it's complaining about it different here. I think this means that it does understand your "myclass" class, but it doesn't understand javax.jms.Destination. That's because Destination is probably from a jar file that was compiled for JDK 1.5. So fine - your JVM is currently 1.4, and you need 1.5 or 1.6.

What I would do is get rid of the JDK 1.4 installation entirely. Or maybe a better idea is to change its directory name to j2sdk1.4_hide or something. So that it won't be found, but you can restore it later if you need to. Then see if the system finds your JDK 1.6 correctly. Or maybe you'll get a different error that can give a clue as to why the system insists on using JDK 1.4 under Ant.

And again, run the short Test.java program (with no javax.jms.Destination) to see what java.version and java.home are pointing to.
[ March 07, 2008: Message edited by: Mike Simmons ]
 
Amir Pourteymour
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is very interesting;

When I compile my class like this :
javac -source 1.4 -target 1.5 JVMVersion.java
it gives me error of "java.lang.UnsupportedClassVersionError: JVMVersion (Unsupported major.minor version 49.0)"

------------------------------------
if I compile them like this javac -source 1.3 -target 1.4 JVMVersion.java
it works very well and gives me JDK versions it is using:
Java Version : 1.6.0_03
Java vendor : Sun Microsystems Inc.
Java home : C:\Program Files\Java\jre1.6.0_03
*************
JVM specification version : 1.0
JVM Version : 1.6.0_03-b05
*************
JRE specification version : 1.6
--------------------------------------
If I again compile them like javac -source 1.3 -target 1.4 JVMVersion.java
and call them from an ant file to run. It returns different JDK version:
[java] Java Version : 1.4.2_05
[java] Java vendor : Sun Microsystems Inc.
[java] Java home : C:\Borland\BDP\jdk\jdk1.4.2\jre
[java] *************
[java] JVM specification version : 1.0
[java] JVM Version : 1.4.2_05-b04
[java] *************
[java] JRE specification version : 1.4

It clearly shows that ANT uses JDK 1.4 inside my code. I checked my ant, and there is no place that I point to a specific JDK. I guess it uses that by default. I would check on that more and come back to you.
[ March 17, 2008: Message edited by: Amir Pourteymour ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

I'm Kelson new to this forum

I will ask almost the same things in this topic
I got the "Unsopported major.minor version 50.0" error

java -version >>
java sersion "1.6.0=07"
java(tm) se runtime environment (build 1.6.0_07-b06)
java hotspot(tm) server vm (build 10.0-b23,mixed mode)
javac -version>>
javac 1.6.0_07
I'm trying to run a simple servlet and I got this error message on my browser.
I'll will really be happy if someone can help me solve this problem
thank


type

message

The server encountered an internal error () that prevented it from fulfilling this request.



javax.servlet.ServletException:
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:534)



java.lang.UnsupportedClassVersionError: HelloWorld (Unsupported major.minor version 50.0)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:539)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
java.net.URLClassLoader.access$100(URLClassLoader.java:55)
java.net.URLClassLoader$1.run(URLClassLoader.java:194)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:187)
java.lang.ClassLoader.loadClass(ClassLoader.java:289)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
java.lang.ClassLoader.loadClass(ClassLoader.java:235)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1301)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:534)
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@adjeiinfo Kelson

Does the version of Tomcat you are using support JDK1.6?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi adjeiinfo and welcome to Javaranch!

Could you please post your question as a separate topic? We try not to Wake The Zombies here
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The issue you're having is that you have more that 1 version of Java installed. the JRE 1.4.2 is actually the one being called by your Java command as it is the registered location for that command. Please see the following:

----------------------------------
#1:
java -version
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

----
#2:
C:\Sun\SDK\jdk\bin\java.exe -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode)

-----------------------------------
In order to use the correct JRE you need to include the entire path like follows:

C:\Sun\SDK\jdk\bin\java.exe MyJavaFile.java
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi and welcome to Javaranch!

We try not to Wake The Zombies here
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I do got the same error when am trying to execute java program in my machine having java 1.6 version. and i found one solution for this as per my experience. In env. variables of Mycomputer, in path system variable i have pasted (java_home\bin;) after my oracle related (oracle92\bin;)

the modification i done to solve this error is:

keep Java_home\bin; environment variable before oracle related bin variable path. this solved the error because
the java related files in oracle are creating problem while we are trying to execute programs.


when i tried to execute same java programs in new command prompt. I got output for all my java programs.
 
reply
    Bookmark Topic Watch Topic
  • New Topic