Dady09
Dady09

Reputation: 659

No default JAVA_HOME on ubuntu 14.04

I'm trying to install tomcat7 using Ansible. After installation, when restarting service, I'm getting errors because there is no java_home set :

no JDK or JRE found - please set JAVA_HOME

I know I can set the java_home value in /etc/default/tomcat7, but what I'm looking for, is why JAVA_HOME is not set by default to the only installed Java and we have to do it manually before starting any Java application/server :

update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java Nothing to configure.

I'm using trusty 14.04 and openjdk8

Upvotes: 0

Views: 1028

Answers (2)

Elliott Frisch
Elliott Frisch

Reputation: 201439

Your JAVA_HOME would appear to be /usr/lib/jvm/java-8-openjdk-amd64, to set it persistently as root create /etc/profile.d/jdk.sh with

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

and make it executable,

sudo chmod 755 /etc/profile.d/jdk.sh

You need to logout and log back in for that to take effect, or you can execute

$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

And it should work as expected.

Upvotes: 1

Anshul Sharma
Anshul Sharma

Reputation: 3522

go to home directory and press ctrl+h and show hidden files then create .bash_aliases file into home folder.

and write two line into .bash_aliases file. /home/hadoop/install/jdk1.8.0_92 by your current jdk path. then restart terminal and check java -version, you get the version details.

export JAVA_HOME=/home/hadoop/install/jdk1.8.0_92
export PATH=$JAVA_HOME/bin:$PATH

Upvotes: 0

Related Questions