| Author |
Compiling servlets
|
Xavi Villalta
Greenhorn
Joined: Aug 02, 2010
Posts: 29
|
|
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
Joined: Nov 24, 2005
Posts: 14672
|
|
|
You need to put the servlets api jar file in your classpath. Check this FAQ.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Xavi Villalta
Greenhorn
Joined: Aug 02, 2010
Posts: 29
|
|
Hmmm
Well I located the servlet-api.jar, but now what?
That ClassPath link was a bit confusing...
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
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
Joined: Jan 10, 2002
Posts: 56185
|
|
|
Yup, the Mac OS is Unix, so file syntax is just like any other Unix system.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Xavi Villalta
Greenhorn
Joined: Aug 02, 2010
Posts: 29
|
|
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
Joined: Aug 11, 2010
Posts: 26
|
|
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
Joined: Nov 24, 2005
Posts: 14672
|
|
"Hari haran the great",
Please check your Private Messages for an important administrative matter.
|
 |
 |
|
|
subject: Compiling servlets
|
|
|