Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling servlets

 
Xavi Villalta
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been trying to get Tomcat to work so that I can compile servelts. When I try to compile them, it says "javax.servlet does not exist".
I don't really know what I'm doing so I need some help!
Thanks.

P.S. I'm using a Mac
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put the servlets api jar file in your classpath. Check this FAQ.
 
Xavi Villalta
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm
Well I located the servlet-api.jar, but now what?
That ClassPath link was a bit confusing...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know the Mac syntax for directories, but I guess it will look something like :
javac -cp /usr/local/jakarta-tomcat-X.X.X/common/lib/servlet-api.jar MyServlet.java

where "/usr/local/jakarta-tomcat-X.X.X/common/lib/" is the full path of your JAR file.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64837
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, the Mac OS is Unix, so file syntax is just like any other Unix system.
 
Xavi Villalta
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember correctly, that command will compile the class?

And then what would I do to test the class?
I tried yesterday to get Tomcat up and running using the Terminal, but when I seached "http://localhost:8080/" (after doing the startup.sh) my browser said it could not find the link.
 
Hari haran Ravi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Xavi.

You must copy the class file(s) that are created by the compiler to the examples directory of TOMCAT. Then you must add references to your class file inside the web.xml file that is in your examples directory of TOMCAT.

If you cant start tomcat, then it might be a problem with the classpath. EITHER CHANGE DIRECTORY TO YOUR TOMCAT DIRECTORY in the terminal and then start the startup.sh file or set a environment variable referencing the home directory of tomcat.

Also it is compulsory that you must have an environment variable referencing the JAVA Home directory.

Hope this information is useful

Regards
Hari
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Hari haran the great",
Please check your Private Messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic