Reputation: 21
On executing sudo ./startup.sh
in CentOS, I am getting the following error:
"Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
But I have already defined it in bashrc in the following way:
export JAVA_HOME=/home/manish/New_learning/jdk1.8.0_212
export PATH=$JAVA_HOME/bin:$PATH
Upvotes: 0
Views: 49608
Reputation: 439
Please Add in
../tomcat/bin/startup.sh
script with below java parameters syntax :
JAVA_HOME=/JDK/path/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export PATH
export JAVA_HOME
Example
JAVA_HOME=/appl/prod/Protine/tomcat/jdk1.5.0_16/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export PATH
export JAVA_HOME
It's working for me , hope it will work for you too.
Upvotes: 0
Reputation: 4487
When you define it in your .bashrc file, it will be OK and well defined for your user.
When you launch the command with sudo, it runs as super-user/root, and NOT as your user; so your .bashrc file is 'useless' in this case.
You should update your environment with a system file like something under /etc/profile.d for instance:
sudo touch /etc/profile.d/variousPath.sh
sudo chown bsquare /etc/profile.d/variousPath.sh
cat >> /etc/profile.d/variousPath.sh <<EOF
export JAVA_HOME=/home/manish/New_learning/jdk1.8.0_212
export PATH=$JAVA_HOME/bin:$PATH
EOF
Reboot your computer, and your SYSTEM environment will know $JAVA_HOME
.
Upvotes: 0