This is gleaned from here.
To get Java code to run locally in conjuction with MAMP follow these steps:
- Download the latest tomcat binary from here.
- Extract and place in your MAMP folder (usually in your application folder).
- Rename the tomcat folder (apache-tomcat-X.X.XX) to tomcat (this is just to ease upgrades I think).
- Add “
/Applications/MAMP/tomcat/bin/startup.sh” to the end of the file
- Add “
/Applications/MAMP/tomcat/bin/shutdown.sh” to the end of the file
- Finally, change the permissions on the following files:
chmod +x startup.sh
chmod +x shutdown.sh
chmod +x catalina.sh
chmod +x setclasspath.sh
chmod +x bootstrap.jar
chmod +x tomcat-juli.jar
The lines in step 4 and 5 could be added to the overall ‘start.sh’ and ‘stop.sh’ but as it requires(?) Apache it doesn’t make sense to have tomcat as a self-contained entity.
Fire up a browser and head to
localhost:8080 to see if all that worked.
Here is a script to do steps 4 to 6:
echo "/Applications/MAMP/tomcat/bin/startup.sh" >> /Applications/MAMP/bin/startApache.sh
echo "/Applications/MAMP/tomcat/bin/shutdown.sh" >> /Applications/MAMP/bin/stopApache.sh
chmod +x /Applications/MAMP/tomcat/bin/startup.sh
chmod +x /Applications/MAMP/tomcat/bin/shutdown.sh
chmod +x /Applications/MAMP/tomcat/bin/catalina.sh
chmod +x /Applications/MAMP/tomcat/bin/setclasspath.sh
chmod +x /Applications/MAMP/tomcat/bin/bootstrap.jar
chmod +x /Applications/MAMP/tomcat/bin/tomcat-juli.jar