aspose file tools*
The moose likes Servlets and the fly likes compiling servlet and tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "compiling servlet and tomcat " Watch "compiling servlet and tomcat " New topic
Author

compiling servlet and tomcat

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
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

Joined: Jan 10, 2002
Posts: 61426
    
  67

You are trying to use a class file that was compiled with a newer version of Java than you are using.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
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

Joined: Aug 30, 2010
Posts: 147

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.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130

Pete Nelson,

Thanks for your opinion
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiling servlet and tomcat