• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling servlet and tomcat

 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to compile a servlet through a batch file [i have installed tomcat ]

note : this program is easily compiled with the help of sun deployment server's file j2ee.jar


batch file code
________________________________________________________

javac -classpath "C:\Tomcat 6.0\lib\servlet-api.jar" *.java

_____
Error _______________________________________________________________


D:\demo tomcat compile>javac -classpath "C:\Tomcat 6.0\lib\servlet-api.jar" *.ja
va
pvaluessrv.java:14: cannot access javax.servlet.http.HttpServlet
bad class file: C:\Tomcat 6.0\lib\servlet-api.jar(javax/servlet/http/HttpServlet
.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 classpa
th.
public class pvaluessrv extends HttpServlet
^
1 error

_______________________________________________________________________
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to use a class file that was compiled with a newer version of Java than you are using.
 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You are trying to use a class file that was compiled with a newer version of Java than you are using.


then ....
1. why it gets compiled with j2ee.jar path .....
2. ...and now i found that it also gets compiled with [jakarta-tomcat-5.0.25] servlet-api.jar path

is there any specific combination kind of mechanism between versions ??
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
j2ee.jar was probably compiled under Java 5. The Tomcat 6.0 servlet-api.jar was compiled under Java 6. When you call "javac" from the command line, it would seem you have a Java 5 compiler, which will be able to use j2ee.jar, but not the Tomcat 6 servlet-api.jar.

You should either look at Tomcat 5.5 for servlet-api.jar, or consider upgrading your JDK to Java 6.
 
abhay jain
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pete Nelson,

Thanks for your opinion
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic