File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Tomcat 6 install on Mac 10.5.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Tomcat 6 install on Mac 10.5.5" Watch "Tomcat 6 install on Mac 10.5.5" New topic
Author

Tomcat 6 install on Mac 10.5.5

B Crosthwaite
Ranch Hand

Joined: Oct 22, 2008
Posts: 39
Hi Everyone

I am trying to install tomcat 6 (6.0.18) on my Mac OS X 10.5.5. so i can use servlets and JSP. I have managed to install tomcat 6 using this guide:
http://www.malisphoto.com/tips/tomcatonosx.html#Anchor-Database

I have changed my JAVA_HOME AND CATALINA_HOME directories.
CATALINA_HOME: /Library/Tomcat/Home
JAVA_HOME: /Library/Java/Home

and when i start tomcat i get this n the terminal:
Using CATALINA_BASE: /Library/Tomcat/Home
Using CATALINA_HOME: /Library/Tomcat/Home
Using CATALINA_TMPDIR: /Library/Tomcat/Home/temp
Using JRE_HOME: /Library/Java/Home

and i can get the tomcat home page ( http://localhost:8080/ )

I think Tomcat is set up correctly, if not please tell me

Now i am presented with 2 different problems.
1st) I cant compile an of my servlets. I get the error "javax.servlet does not exist" and "javax.servlet.http does not exist"
2nd) When i just place a JSP in the ROOT folder i get the all too familiar 404 error

Please can someone help me, iv been trying to get this sorted for days now :P

Thanks,
-Ben C
[ October 23, 2008: Message edited by: B.Crosthwaite ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
How are you compiling the servlets? Is the servlet jar file in your classpath? Something like "javac -classpath $TOMCAT_HOME/common/lib/servlet-api.jar MyServlet.java" should do the trick.

The 404 problem is odd; that should work. But I'd leave the ROOT context alone, and create a separate directory instead, next to the ROOT directory. If you then create a WEB-INF directory inside of it, Tomcat will recognize it as a web app, and execute any JSPs you put in there.
[ October 23, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
B Crosthwaite
Ranch Hand

Joined: Oct 22, 2008
Posts: 39
Thank you Ulf. This does make sence, but I have been a bit confused with the whole classpath thing. I will try this as soon as I can (I am at work at the moment :P )

-Ben
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

Originally posted by B.Crosthwaite:
but I have been a bit confused with the whole classpath thing.


What is the confusion? $TOMCAT_HOME is the Tomcat installation directory.


SCJP, SCWCD.
|Asking Good Questions|
B Crosthwaite
Ranch Hand

Joined: Oct 22, 2008
Posts: 39
As far as the installation of tomcat goes this is my first time.

Is there a less time consuming way of compiling my servlets than this?
"javac -classpath $TOMCAT_HOME/common/lib/servlet-api.jar MyServlet.java"

-Ben
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Once you progress past the beginning stages with your web projects, you'll likely start using a build system (like Ant) or an IDE. Either of those can take care of adding all required jar files to your classpath without you having to type them in every time.

Also, on OS X, you can add jar files to your classpath permanently by putting them into the /Library/Java/Extensions directory. Any jar files in that directory will be added to the classpath automatically.
B Crosthwaite
Ranch Hand

Joined: Oct 22, 2008
Posts: 39
I might be getting a bit ahead of my self here, but please be patient

For Example, if i create:
CLASSPATH $TOMCAT_HOME/lib/
This would possibly solve my problem?

-Ben
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
This can be answered in a couple of ways. The easy one is, it might help you once you get the semantics of the classpath right. The classpath does not point to directories that contain jar files, it points to the jar files themselves. So setting CLASSPATH to $TOMCAT_HOME/common/lib/servlet-api.jar might work.

The more complex answer is: don't use CLASSPATH. Explaining why requires more time than I have, but that's something I've come to learn over the years. It gets more in the way than it helps, maybe not right now for you, but eventually it will. I'd advise to use the "-classpath" option instead. You said earlier that that was time-consuming, but you only really need to type that once, and then you use the up arrow in the console to re-execute the command, so it's not like you need to type it all the time.

You might also want to become familiar with Ant, which addresses all these issues. But I'd advise you to wait a bit, until you've learnt the ins and outs of using Java via the command line, and have a good understanding of the classpath.
B Crosthwaite
Ranch Hand

Joined: Oct 22, 2008
Posts: 39
yes, ok. Point taken, i think your rite. I need to familiarise my self with the basics first i think.

May i just ask another question, it may sound a bit silly but....
What does the "-classpath" part of the javac statement mean, and what is do?

Thank you,
-Ben
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

It tells the compiler where the class files can be found that are required to compile this particular file.Same thing can be done using the -cp option (for lazy ones like me ). But the -classpath is recommended simply because its more readable than -cp
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

And now since this topic is inclined towards compiling servlets and setting the classpath and all, I am moving this to the Beginners forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat 6 install on Mac 10.5.5
 
Similar Threads
Troubles Tomcat Install
Tomcat installation on Linux.. need help..
javax.servlet does not exist
Tomcat - Linux gettin alert msgs after installation
configuring tomcat in win98