participate


Java Compiler - 1.5: class file has wrong version 49.0, should be 48.0 [Locked]
This topic is locked
<<   Back to Forum  |   Give us Feedback Topics: « Previous | Next
3 Duke Stars available
This topic has 64 replies on 5 pages.    1 | 2 | 3 | 4 | 5 | Next »
jpaulkeller
Posts:129
Registered: 6/27/99
1.5: class file has wrong version 49.0, should be 48.0   
Apr 28, 2004 1:25 PM

 
Hi -- I just downloaded the 1.5 SDK, and I am unable to compile any
of my code (which was compiling fine in 1.4).

This is the error I get:

bad class file: C:\pkgs\j2sdk1.5.0\jre\lib\rt.jar(java/
class file has wrong version 49.0, should be 48.0

I've tried different -source and -target options with no luck.

It's like I have a bad rt.jar file or something, but I've tried it on
different machines with the same result. I assume I'm missing
something obvious... please fill me in, thanks!
 
shankar.unni
Posts:749
Registered: 6/23/98
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Apr 29, 2004 10:34 AM (reply 1 of 64)  (In reply to original post )

 
bad class file:
C:\pkgs\j2sdk1.5.0\jre\lib\rt.jar(java/
class file has wrong version 49.0, should be 48.0

Check to see which javac and java you're running. (Check your PATH, and see which java and javac are being picked up). This looks like you're using a JDK 1.5 library, with a JDK 1.4 VM.
 
jpaulkeller
Posts:129
Registered: 6/27/99
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Apr 30, 2004 12:08 PM (reply 2 of 64)  (In reply to #1 )

 
Actually, it turned out to be a bad jar file in our lib/ext... kind of weird. When we removed that jar, everything compiled fine. Thanks.
 
ranjanbaisak
Posts:67
Registered: 7/12/00
Re: 1.5: class file has wrong version 49.0, should be 48.0   
May 31, 2004 3:43 AM (reply 3 of 64)  (In reply to #2 )

 
I am facing the same problem. Can anybody help me out?
 
ranjanbaisak
Posts:67
Registered: 7/12/00
Re: 1.5: class file has wrong version 49.0, should be 48.0   
May 31, 2004 6:30 AM (reply 4 of 64)  (In reply to #3 )

 
I got it solved by myself. I had jdk 1.4.2 and java home was referring to jdk1.4.2 so modified java home to refer to jdk 1.5.0 .
 
MartinHilpert
Posts:3,418
Registered: 10/24/97
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Feb 3, 2005 4:32 AM (reply 5 of 64)  (In reply to #4 )

 
Same problem, different solution: my ANT configuration in Eclipse referenced 1.4 libs while I was using 1.5.
 
jwenting
Posts:9,582
Registered: 4/17/98
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Feb 3, 2005 7:25 AM (reply 6 of 64)  (In reply to #5 )

 
49 is the correct classfile version for 1.5.
If you're getting this error your runtime is 1.4 or earlier while your compiler is 1.5.

Nothing wrong with the JDK, only with your system configuration.
Most likely you have old java and javaw exes somewhere on your path which can get loaded in preference to the ones in your JDK installation.
 
Vanessa
Posts:1
Registered: 2/5/05
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Feb 5, 2005 7:53 PM (reply 7 of 64)  (In reply to #6 )

 
I'm having this exact same problem but I'm not too sure on how to fix it. I've tried following the replies but I'm just even more confused.

What I sort of understand is the runtine and compiler both has to be set to 1.5. But the runtime is in 1.4 right? How can I fix this so I have both to 1.5.

I just recently uninstalled and reinstalled 5 Java environments in my computer which is probably why I'm so frustrated with this. Please let me know which one I dont need if there is any.

They are:
J2SE DEvelopment Kit 5.0 Update 1
J2SE Runtime environment 5.0 Update 1
Java 2 Platform Enterprise Edition 1.4 SDK
Java 2 Runtime Environment SE 1.4.2_07
Java 2 SDK SE 1.4.2_07
 
ChuckBing
Posts:13,470
Registered: 4/7/01
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Feb 5, 2005 9:00 PM (reply 8 of 64)  (In reply to #7 )

 
Background information:
Java 1.4 creates class files labeled with version 48.0
Java 1.5 creates class files labeled with version 49.0

Java 1.4 can't run class files labeled with version 49.0

If you are getting the error, that means that you're trying to run using Java 1.4 - either you're doing it, ir (more likely) your PATH environment variable is set so that Java 1.4 is before 1.5 in the path, and it executes rather than 1.5

Solution: change (something!) so that 1.5 runs class files labeled 49.0.

Unless you need multiple Java versions, you can delete all except the two 5.0 entries.
 
Gregers
Posts:1
Registered: 2/16/05
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Feb 16, 2005 6:25 AM (reply 9 of 64)  (In reply to #5 )

 
Could you please explain exactly you changed which libs were referenced by your Ant configuration in Eclipse? I have tried, in Eclipse 3.0, Window > Preferences > Ant > Runtime > Classpath > Global Entries -- in which I added the path to my Java 1.5 tools.jar file, but to no avail. Ant still tells me, upon trying to run javac, "class file has wrong version 49.0, should be 48.0".
 
petka535
Posts:4
Registered: 3/5/02
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Feb 16, 2005 8:03 AM (reply 10 of 64)  (In reply to #9 )

 
Gregers:

Check the value of your JAVA_HOME environment variable and make sure that this doesn't point to a 1.4 installation. After you've changed it, restart Eclipse so that it picks up the new value of the variable.
 
vishakha_s
Posts:1
Registered: 2/26/04
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Mar 10, 2005 1:08 AM (reply 11 of 64)  (In reply to #10 )

 
i am facing the same problem
i am trying to use struts
my other jsp file were get compiled properly but
when i used struts taglibs to create a jsp file i got the error
class file has wrong version 49.0, should be 48.0
i checked JAVA_HOME variable and class path
they are pointing to jdk 1.5 only
*******************
error as displayed by tomcat

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

D:\Program Files\Apache Software Foundation\Tomcat 5.5\work\Catalina\localhost\strutsProject\org\apache\jsp\userRegistration_jsp.java:7: cannot access java.lang.Object
bad class file: D:\Program Files\Java\jre1.5.0_01\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public final class userRegistration_jsp extends org.apache.jasper.runtime.HttpJspBase
^
1 error


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.

Is there a conflict between the versions of struts(i am using struts 1.2.4)and jdk 1.5
please help me
thanks in advance
 
jwenting
Posts:9,582
Registered: 4/17/98
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Mar 10, 2005 6:34 AM (reply 12 of 64)  (In reply to #11 )

 
You need to hack the 1.5 runtime into Tomcat as it comes with the 1.4 runtime as distributed.
It's not hard, just find tools.jar in your Tomcat installationand replace that with the copy from your JDK installation and you're in business.
 
.martin.
Posts:1
Registered: 3/11/05
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Mar 11, 2005 8:11 PM (reply 13 of 64)  (In reply to original post )

 
had same problem with tomcat running in debug mode in eclipse
eclipse was configured with jre1.5 but tomcat needs jdk1.5 to compile jsp

after i configured jdk1.5 with eclipse and restarted tomcat everything compiled.
 
DYNAGENT
Posts:1
Registered: 3/12/05
Re: 1.5: class file has wrong version 49.0, should be 48.0   
Mar 12, 2005 10:45 AM (reply 14 of 64)  (In reply to original post )

 
Problem with old version of tool.jar on Application Servers.

Application Server with Autodeploy use tool.jar to access javac, so if you update
your JDK and your JRE and your System path, but you dont update your tool.jar copy in your Application Server, you wil have this problem because an old javac cant exe new class files.

Alfonso
 
This topic has 64 replies on 5 pages.    1 | 2 | 3 | 4 | 5 | Next »
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 25
  • Guests : 145

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums