Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class file has wrong version 50.0, should be 49.0

 
Ed Connery
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, both give me version 1.5.0_12 (build 1.5.0_12-b04).
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you able to compile and run this program without using any IDE?
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic