Linux下找到真正的JDK路径,从而解决默认编译安装Java后不知道jdk路径,以至于无法启动Tomcat的问题。
输入:
[root@cheng java]# ls -lrt /usr/bin/java
lrwxrwxrwx 1 root root 22 Feb 9 18:22 /usr/bin/java -> /etc/alternatives/java
[root@cheng java]# cd /etc/alternatives/java
发现:
lrwxrwxrwx 1 root root 39 Feb 9 18:22 java -> /usr/lib/jvm/jre-1.7.0-openjdk/bin/java
lrwxrwxrwx 1 root root 30 Feb 9 18:22 jre -> /usr/lib/jvm/jre-1.7.0-openjdk
lrwxrwxrwx 1 root root 30 Feb 9 18:22 jre_1.7.0 -> /usr/lib/jvm/jre-1.7.0-openjdk
真实目录在这里:
[root@cheng bin]# cd /usr/lib/jvm/jre-1.7.0-openjdk
[root@cheng jre-1.7.0-openjdk]# ll
total 8
drwxr-xr-x 2 root root 4096 Feb 9 18:22 bin
drwxr-xr-x 10 root root 4096 Feb 9 18:22 lib
那么在 /etc/profile里需要这样配置java环境:
export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk/
export CALSSPATH=$JAVA_HOME/lib/*.*
export PATH=$PATH:$JAVA_HOME/bin
export TOMCAT_HOME=/opt/tomcat7
export CATALINA_HOME=/opt/tomcat7
这样就能正常启动Tomcat了,而不是提示启动成功,实则没有启动。