Reputation: 774
I've downloaded java jdk1.8.0.7.tar.gz file from the official website and unzipped it into my home directory. Now to set the $JAVA_HOME
variable I used the follwing commands command nano .bashrc
and then appending export $JAVA_HOME=/home/shivam/Java/jdk1.8.0.7
at the end of the file .
But whenever I run the command sudo $CATALINA_HOME/bin/startup.sh
I get an error message saying
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
I don't understand why it is unable to find the java path though I've installed tomcat and set its home variable the this way, which worked.
I wan't to install Java manually without using apt-get
.
Kindly guide .
Upvotes: 0
Views: 706
Reputation: 8387
Try add the following 2
lines in your .bashrc
file:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7/
export JAVA_HOME
Upvotes: 0
Reputation: 4462
You want to append the following to .bashrc:
JAVA_HOME=/home/shivam/Java/jdk1.8.0.7
Note the missing $
at the start.
Also remember that the file won't effect your current shell without source
ing it first.
Also, when running a command with sudo
, you are running it as the root
user, not as yourself. So the environment variable needs to be set for the root user, not yourself.
You can run sudo env | grep JAVA_HOME
to see whether it is set for root.
Upvotes: 3