aspose file tools*
The moose likes Cattle Drive and the fly likes class file has wrong version 50.0, should be 49.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "class file has wrong version 50.0, should be 49.0" Watch "class file has wrong version 50.0, should be 49.0" New topic
Author

class file has wrong version 50.0, should be 49.0

Ed Connery
Ranch Hand

Joined: Mar 11, 2010
Posts: 70
I'm working on Servlets-4a and trying to compile VideoData.java. The compiler is complaining, specifically:

"class file has wrong version 50.0, should be 49.0"

So I know that means the version is for 1.6 when I need 1.5, but my javac version is 1.5.0_12.

What have I done this time?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

My first guess is that you're compiling with a newer version of java than you're running with.

Try:

java -version
javac -version

Do these give the same value?
Ed Connery
Ranch Hand

Joined: Mar 11, 2010
Posts: 70
Yes, both give me version 1.5.0_12 (build 1.5.0_12-b04).
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

Hmm, plus you're getting it at compile time, not run time, so the java runtime version isn't relevant. How exactly are you compiling? Just, "javac VideoData.java", or with along with the other Java files, or through ant?
Ed Connery
Ranch Hand

Joined: Mar 11, 2010
Posts: 70
Good question! I was compiling through ant. Simplifying to javac VideoData.java, the compilation works. Retrying via ant fails, so maybe I was focusing on the wrong part of the error messages. Let's give more complete text:

gyan kumar
Ranch Hand

Joined: Sep 28, 2011
Posts: 61
Are you able to compile and run this program without using any IDE?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

Well, that's confusing. It looks like the error is on VideoServlet.java. VideoData.java has already been compiled, but somehow has the wrong version in it. Have you tried "ant clean"? It's just possible that you have an old class file hanging out there somehow. Also, I believe the JDK version used by ant is going to be what is specified in the JAVA_HOME environment variable. You should make sure that matches up with the version that you'd get from running from a command, that is, the one you get from your path.
Ed Connery
Ranch Hand

Joined: Mar 11, 2010
Posts: 70
ant clean did the trick! (Now of course I have to get it to WORK now that I can get it to compile. Details, details.)

For future reference, JAVA_HOME does point to the same version.

gyan: No IDE involved here. Just to keep life simple, I have the Cattle Drive with no IDE, a Sun Java course using NetBeans, and a work project using Eclipse. Three different web servers, too. No, I don't know which way is up!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class file has wrong version 50.0, should be 49.0