I am trying to install some software (Shibboleth) in Ubuntu 14.04. I already have Java 7 OpenJDK installed in /usr/lib/jvm/
, and I have these lines in /usr/environment
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export JAVA_HOME
If I type echo $JAVA_HOME
I correctly get /usr/lib/jvm/java-7-openjdk-amd64
.
However, when I try to install Shibboleth I always get Error: JAVA_HOME is not defined correctly. Cannot execute java
.
Interestingly, if I type java
command it works (it refers to /usr/lib/java which is a link to the right one). However, when I try to run bash bin/install.sh
of Shibboleth, I get the JAVA_HOME error
I already tried setting JAVA_HOME
to the jre
folder with same result. Any ideas?
Add both JAVA_HOME
& PATH
to your ~/.profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
And, add following to your /etc/profile.d/java.sh
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JAVA_HOME
PATH=${JAVA_HOME}/bin:${PATH}
export PATH
JRE_HOME=/usr/lib/jvm/jre
export JRE_HOME
JAVA_OPTS="-XX:+AggressiveOpts -Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
export JAVA_OPTS
For more info, Refer Documentation
Hope it helps.
Instead of
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
I did
EXPORT JAVA_HOME='/usr/lib/jvm/java-1.7.0-openjdk-amd64'
Works.
According to Your editor.
sudo vim /etc/profile
add these 2 lines at the end of the file
export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
export PATH=JAVA_HOME/bin:$PATH
Then
source /etc/profile
Check
mvn -version
you should set the path to bin folder where java, javac files are found. In your case it might be /usr/lib/jvm/java-7-openjdk-amd64/bin
I issue is that the install.sh script which you are running has the java path wrong.
Edit the file using nano
sudo nano idp-install.sh
or vim editor
vim idp-install.sh
and change the line which corresponds to java path and add the correct java path. This will solve your problem.
P.S. This solution is specific to the java path for Shibboleth installation.
from Ubantu terminal execute:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
to test maven run:
mvn --version
it will give output:
Maven home: /usr/share/maven
Java version: 1.7.x.xxx, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-47-generic", arch: "amd64", family: "unix"
来源:https://stackoverflow.com/questions/34966648/java-home-is-not-defined-correctly-on-ubuntu