aspose file tools*
The moose likes Java in General and the fly likes Compiling servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Compiling servlets" Watch "Compiling servlets" New topic
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: 14687
    
  16

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: 14687
    
  16

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: 61221
    
  66

Yup, the Mac OS is Unix, so file syntax is just like any other Unix system.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 14687
    
  16

"Hari haran the great",
Please check your Private Messages for an important administrative matter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiling servlets