![我无法在 centos 浏览器中连接 tomcat,但它从终端启动](https://linux22.com/image/83731/%E6%88%91%E6%97%A0%E6%B3%95%E5%9C%A8%20centos%20%E6%B5%8F%E8%A7%88%E5%99%A8%E4%B8%AD%E8%BF%9E%E6%8E%A5%20tomcat%EF%BC%8C%E4%BD%86%E5%AE%83%E4%BB%8E%E7%BB%88%E7%AB%AF%E5%90%AF%E5%8A%A8.png)
当我输入时./startup.sh
我得到:
Using CATALINA_BASE: /home/ashok/apache-tomcat-7.0.56
Using CATALINA_HOME: /home/ashok/apache-tomcat-7.0.56
Using CATALINA_TMPDIR: /home/ashok/apache-tomcat-7.0.56/temp
Using JRE_HOME: /usr/java/jdk1.7.0_05/bin/java
Using CLASSPATH: /home/ashok/apache-tomcat-7.0.56/bin/bootstrap.jar:/home/ashok/apache-tomcat-7.0.56/bin/tomcat-juli.jar
/home/ashok/apache-tomcat-7.0.56/bin/catalina.sh: line 319: /usr/java/jdk1.7.0_05/bin/java/bin/java: No such file or directory
/home/ashok/apache-tomcat-7.0.56/bin/catalina.sh: line 319: exec: /usr/java/jdk1.7.0_05/bin/java/bin/java: cannot execute: No such file or directory
答案1
说的很清楚。尝试理解错误消息。这JRE_HOME应该 /usr/java/jdk1.7.0_05/不是/usr/java/jdk1.7.0_05/bin/java
答案2
请添加到您的/etc/profile:
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
登录并注销才能生效。
这样做的好处是你不必每次更新 Java 时都更新它。