首页 > 代码库 > Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program

开启tomcat时出现以上错误

// 进入root帐户 在普通用户也可以

sudo -s

//用编辑器打开.bashrc文件

gedit .bashrc 在普通用户下注意加上sudo

//在最后一行添加环境变量(文件位置根据自己的实际情况)

JAVA_HOME=/usr/local/java/jdk1.7.0_67
CLASSPATH=.:/usr/local/java/jdk1.7.0_67/lib
JRE_HOME=/usr/local/java/jdk1.7.0_67/jre
PATH=$PATH:/usr/local/java/jdk1.7.0_67/bin

//重启生效。

//给tomcat文件夹及所有文件赋予权限777

chmod 777 /opt/tomcat -R

//开启tomcat服务

/opt/tomcat/bin/startup.sh