0

I am having big problems compiling java servlets. As far as I can see, I've done everything I need to do, I've installed Tomcat 7 correctly, and Tomcat is working. As I understand, I need to add servlet.jar package to my classpath.

I've done this, by editing the classpath environment variables:

CLASSPATH=C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar

Unfortunately, still no luck, I can't compile java servlets, and I am still get warnings about missing symbols for javax.servlets.

I am using Window 7. Any ideas?

Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143
Mo-
  • 23
  • 3
  • How are you compiling? from command prompt? – kosa Nov 01 '12 at 15:00
  • 1
    I'm sure the compiler doesn't just say: "I can't compile that". It comes with a specific error message, which refers to the lines of code that don't compile. Show us the code, and show us the error message. It's meaningful, and is intended to be read. Also, you shouldn't set the CLASSPATH like that. Pass it as a `-cp` option to javac. – JB Nizet Nov 01 '12 at 15:14
  • yes, what is the error/exceptions.. please show us. – Jasonw Nov 01 '12 at 15:20
  • If compiler complains something like `can not find javax.servlet`, this is sure it can not find the right jar files, you need to set it correctly. or use can use a `.bat` file to write a script with the classpath and call it on `cmd`. – Amit Yadav Nov 01 '12 at 15:33

1 Answers1

0

Tomcat already comes with Servlet related stuff jar files. You don't need to worry about them. You have make them available for your application to compile by adding those in your classpath. But not including into the application build.

If your compiler complains about javax.servlets. so you are missing the Java EE jar in your classpath. You need to add the Java EE jar file to your classpath (the application classpath). You can download them following this. But make sure you do not include them into your build.

Community
  • 1
  • 1
Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143