java and tomcat on mac

编辑 ~/.profile:

JAVA_HOME=/Library/Java/Home

 

echo $JAVA_HOME

/Library/Java/Home

java -version

openjdk version "1.7.0-ea"

OpenJDK Runtime Environment (build 1.7.0-ea-b211)

OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

 

下载最新的Tomcat二进制编码包,解压,移动到根目录/Library(资源库)中(别处也可)

 

更改权限:

sudo chmod 755 /Library/Tomcat7.0.23/bin/*.sh 

Password:

sudo chmod 755 /Library/Tomcat7.0.23/bin/*.bat 

 

启动,测试:

 

/Library/Tomcat7.0.23/bin/startup.sh

Using CATALINA_BASE:   /Library/Tomcat7.0.23

Using CATALINA_HOME:   /Library/Tomcat7.0.23

Using CATALINA_TMPDIR: /Library/Tomcat7.0.23/temp

Using JRE_HOME:        /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home

Using CLASSPATH:       /Library/Tomcat7.0.23/bin/bootstrap.jar:/Library/Tomcat7.0.23/bin/tomcat-juli.jar

 

编写启动脚本到/usr/bin/tomcat文件:

 

sudo touch /usr/bin/tomcat
Password:
sudo vim /usr/bin/tomcat

 

#!/bin/bash

case $1 in 

start) 

sh /Library/Tomcat7.0.23/bin/startup.sh 

;; 

stop) 

sh /Library/Tomcat7.0.23/bin/shutdown.sh 

;; 

restart) 

sh /Library/Tomcat7.0.23/bin/shutdown.sh 

sh /Library/Tomcat7.0.23/bin/startup.sh 

;; 

*) 

echo “Usage: start|stop|restart” 

;; 

esac 

exit 0 


启用:

sudo chmod 755 /usr/bin/tomcat 

tomcat start

tomcat stop

 

参考:http://lam.iteye.com/blog/776967

你可能感兴趣的:(tomcat)