$ cd /System/Library/Frameworks/JavaVM.framework/Versions
$ 'ls' -l CurrentJDK
lrwxr-xr-x 1 root wheel 5 May 11 16:36 CurrentJDK -> 1.4.2
$ sudo rm CurrentJDK
$ sudo ln -s 1.5.0 CurrentJDK
lrwxr-xr-x 1 root wheel 5 May 12 09:47 CurrentJDK -> 1.5.0
$ java -versionYou should get the output:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-56)For other Mac OS X Java related information see http://developer.apple.com/java/index.html
Java HotSpot(TM) Client VM (build 1.5.0_02-36, mixed mode, sharing)
create database javatest;Where obviously, the 'test_password' is replaced with your own password . Don't use the root password (created above) for this. Also, don't change the database name "javatest" because it's a default name used below.
grant all on javatest.* to 'test_mysql_login'@'localhost' identified by 'test_mysql_password';
flush privileges;
Download the 5.x version of Tomcat. For me the filename was apache-tomcat-5.5.12.tar.gz
$ sudo mv apache-tomcat-5.5.12.tar.gz /usr/localCreate the directory /usr/local/apache-tomcat-5.5.12:
$ cd /usr/local/
$ gnutar -xzvf apache-tomcat-5.5.12.tar.gzThe following permits you to use /usr/local/tomcat to access tomcat files:
$ sudo rm apache-tomcat-5.5.12.tar.gz
$ sudo ln -s apache-tomcat-5.5.12 tomcatChange the ownership of the Tomcat files to "myusername" (replace with your login username):
$ sudo chown -R myusername: apache-tomcat-5.5.12Setup the CATALINA_HOME environment variable to point to /usr/local/tomcat for your shell. See Setting Up the JAVA_HOME Environment Variable above.
Create bin directory and make it your current directory:
$ cd; mkdir bin; cd binNow you can create a file called start_tomcat with the following contents (this assumes the JAVA_HOME environment variable was defined above):
#!/bin/shAnd create another file called stop_tomcat with the following contents:
export CATALINA_HOME=/usr/local/tomcat
$CATALINA_HOME/bin/startup.sh
export CATALINA_HOME=/usr/local/tomcat
$CATALINA_HOME/bin/shutdown.shAdd /Users/myusername/bin to your PATH environment variable, where myusername is replaced with your login name. If you're using the csh or tcsh shell add the following to the ~/.tcshrc file:
Make the two scripts you just created executable:
$ chmod u+x *_tomcat
setenv PATH ${PATH}:/Users/myusername/binIf you're using the Bash shell, add the following to your ~/.bash_profile file:
export PATH=${PATH}:/Users/myusername/binYou can now use start_tomcat and start_tomcat to start and stop the tomcat server. Sometimes it takes Tomcat a little while to startup, say 10-20 seconds. Use the "top" shell command (terminal command) watch Tomcat CPU usage during startup. When usage dies down to near zero, it's done starting up. If tomcat is running the web page http://localhost:8080 should display:

As mentioned on the Tomcat welcome page, you should setup usernames and passwords in the file $CATALINA_HOME/conf/tomcat-users.xml . My entry looks like this (with italics replaced appropriately):
<user username="myusername" password="mypassword" roles="tomcat,admin,manager"/>You have to stop and restart Tomcat after adding users and/or changing passwords in Tomcat.
$ sudo ln -s mysql-connector-java-3.1.11 mysql-connector-javaWhere mysql-connector-java-3.1.11 is replaced with whatever version you downloaded.
$ cd $CATALINA_HOME/common/libNext you need to create the file $CATALINA_HOME/webapps/MyApps/META-INF/context.xml with the following content (substituting for test_mysql_login and test_mysql_password appropriately):
$ sudo ln -s /usr/local/mysql-connector-java-3.1.11/mysql-connector-java-3.1.11-bin.jar mysql-connector-java-3.1.11-bin.jar
| <Context reloadable="true" > <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="test_mysql_login" password="test_mysql_password" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/> </Context> |