You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Here are some notes on getting Java and Tomcat to run on a Max with OSX (10.3.5 as at this writing).

These notes are the result of several weeks playing with different things and asking a LOT of questions on several mailing lists.

The following assumes you have Java already installed - it is installed by default on every Mac OSX or later - but I thought I'd issue a caveat.

I hope these notes are of use to someone out there.

THE SITUATION'

I wanted to learn about JSP on my Mac with OSX. I installed it first time on a WinXP Pro PC but my development machine is a Mac.

THE SOLUTION

Because I had already installed and played with a separate install of Tomcat (the one installed by Apple's XCode was out of date as was the one I downloaded from another site), I was ready to give up!

In my case I wanted to get rid of all the other installations and start from scratch.

#1 Download Jakarta Tomcat - use the Binaries line - I d/loaded jakarta-tomcat-5.0.27.tar.gz

Extract the files (unless your browser automatically extracts them).

Navigate (using the Finder) to Macintosh HD > Library.

If there is not already a folder in Macintosh HD > Library called Tomcat then create one.

If there is already a Tomcat folder (my situation) but the Tomcat installed is out of date then delete all the files already in that folder.

#2 Copy all the unstuffed files from the "jakarta-tomcat-5.0.27.tar.gz" download and put all the files into the Tomcat folder.

I just named it Tomcat as it saves some typing in the Terminal (smile)

So the directory structure becomes:

Macintosh HD > Library > Tomcat > <extracted files>

#3 We then need to set the JAVA_HOME environment variable - this is almost the same as setting the WinXP Environment Variable.

Download the preference pane "RCEnvironment" (http://www.rubicode.com/Software/RCEnvironment/)

Copy the Pref Pane to Macintosh HD > Library > PreferencePanes

Go to System Preferences and click the Pane for "Environment Variables"

JAVA_HOME is defined as /Library/Java/Home.

In the left hand column enter "JAVA_HOME" and in the left hand column enter "/Library/Java/Home". Click Apply.

#4 Open the /Library/Tomcat/conf/tomcat-users.xml file with a plain text editor. As a default MacOSX installation Tomcat only has basic roles and users set up.

What is configured as default is:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

An example of what it *SHOULD* look like follows:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat,admin,manager"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

In this case a role, a user and password have been set up with the name "tomcat". You can change this later.

#5 Reboot.

#6 To start Tomcat go to Terminal.

The path to Tomcat via the Finder is Macintosh HD > Library > Tomcat.

But to get to that directory using the Terminal, type in:

cd /Library/Tomcat/bin

Do an "ls" - you should see a file called "startup.sh"

Any shell (".sh") file can be executed in the terminal by putting period and a slash before the file name (eg: startup.sh) executes the shell script.

./startup.sh

Terminal should display 4 lines looking like this:

Using CATALINA_BASE: /library/tomcat Using CATALINA_HOME: /library/tomcat Using CATALINA_TMPDIR: /library/tomcat/temp Using JAVA_HOME: /Library/Java/Home Users-Computer:/library/tomcat/bin user$

Wait about 30 seconds.

(There are some notes and a couple of Preference Panes for automating the starting and stopping of Tomcat. After trying them all on 5 different computers - this is the simplest!)

#7 Open a browser window - enter "127.0.0.1:8080" - the default Tomcat page should open.

If you click the Tomcat Administrator or Tomcat Manager links in the upper left hand of the default Tomcat page you will be asked for a user name and password.

As mentioned above, use "tomcat" and "tomcat".

By : Brynley Blake (31 August 2004)

With CONSIDERABLE help from Joachim, Tracy, Tom, Samuel and Jonel from the Apple Web and Java Developer mailing lists.

  • No labels