When I check maven Version
$ mvn -version
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/java-8-oracle/bin/java
How to solve it ?
these are my java jdk version.
$ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
Make sure your JAVA_HOME variable is set to the JRE folder, like this:
/usr/lib/jvm/java-8-oracle/jre
To further improve your setup, you can let Java pick the correct version by putting this in your JAVA_HOME (this assumes you used the Oracle installer):
export JAVA_HOME=$(/usr/libexec/java_home)
If this doesn't work for you, make sure permissions are set correctly (Execute permissions on the binaries)
Related
I created a new conda environment with the command conda create --name condaenv python=2.7 openjdk=8. When I activate this environment using conda activate condaenv and check the java version, however, I get:
openjdk version "1.7.0_91"
OpenJDK Runtime Environment (Zulu 7.12.0.3-linux64) (build 1.7.0_91-b15)
OpenJDK 64-Bit Server VM (Zulu 7.12.0.3-linux64) (build 24.91-b15, mixed mode)
How can I get the correct java version for this conda environment?
I checked that the JAVA_HOME environmental variable is correct, and it is since running echo $JAVA_HOME gives /home/ag956/.conda/envs/condaenv
I solved the issue by first installing Java 1.8 with the command:
conda install -c main java-1.8.0-openjdk-cos7-s390x
And then creating the environment.
I have install JDK 8 and my environment path is
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/java-8-openjdk"
PATH=$PATH:/usr/lib/jvm/java-8-openjdk/bin
Here is my Java version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
I am getting problem while installing Maven on Ubuntu
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Just run update-alternatives --config java this should gives you the path to the java home.
After this you can set your JAVA_HOME path simply. Just edit your ~/.bashrc and add this line export JAVA_HOME=<path_given_by_the_command above>. After this reload your bashrc.
Once you have installed oracle JDK on your Ubuntu then run below command to set JDK as default
sudo apt install oracle-java8-set-default
This will set environment variable path and you don't need to change config files manually.
Try getting the path using readlink
export JAVA_HOME="$(readlink -f /etc/alternatives/java | sed -e 's/\/jre\/bin\/java$//')"
when I run cordova run android in my project I have this output
ANDROID_HOME=/home/ronaizacard/Android/Sdk/
JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre/bin/java
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-7-oracle/jre/bin/java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Error: /home/ronaizacard/work/apk/platforms/android/gradlew: Command failed with exit code
However, when I check the JAVA_HOME variable I get:
# echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle/jre/bin/java
My JAVA_HOME is defined in .zshrc and I have double checked that it is set as the source.
JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre/bin/java
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Running java -version also confirms that JAVA_HOME is set correctly and is on the PATH.
➜ ~ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
So my question is how/why does Gradle find /usr/lib/jvm/default-java, and more importantly how do I point it to the correct directory?
I have also tried find the Gradle files and change the /usr/lib/jvm/default-java on bin but cordova dont have this
I'm running 64bit Ubuntu LTS 16
I change JAVA_HOME=/usr/lib/jvm/java-7-oracle and worked fine
Going on nearly 2 days wasted trying to get maven properly installed. These are my outputs. Why in the world is maven defaulting to some jdk I don't even have??? I have tried a million different solutios proposed from goole searches and nothing!!! Help. I have not made any changes to any config files such as mvn.sh.
System: Mac
OS=Yosemite 10.10
Java=Oracle 1.8 JDK
contents of .bash_profile:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
export M2_HOME=/usr/local/Cellar/maven/3.2.3
export M2=$M2_HOME/bin
export PATH=$PATH:$M2_HOME/bin
terminal commands:
java -version ->
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
mvn -version ->
Error: JAVA_HOME is not defined correctly.
We cannot execute /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java
If anyone else happens to run into this the crazy stupid solution was that I had an old .mavenrc file in home directory that was causing the conflict.
I have installed java with the command sudo apt-get install openjdk-7-jdk and set the java home and path.But when I am trying to use ant I
JAVA_HOME is not defined correctly.
We cannot execute /usr/local/java/jre1.7.0_60/bin/java
Please help me how to resolve this error.
which java ----> /usr/bin/java
java -version ---->java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
echo $JAVA_HOME -----> /usr/local/java/jre1.7.0_60
I had same problem than you. Try using Oracle jdk instead openjdk
To change OpenJdk by Oracle JDK you can do (you have to download oracle jdk first):
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_37/bin/java" 1
Here you have a detailed explanation:
http://hendrelouw73.wordpress.com/2012/11/09/how-to-install-oracle-java-6-0-37-on-ubuntu-12-04-linux/
You can set your environment by doing:
vi /etc/environment
in my case I did:
PATH="/usr/lib/jvm/java-6-sun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME="/usr/lib/jvm/java-6-sun/"
and it solved my problem
Ant requires JDK and you have installed JRE. So ant is throwing such an error.
So, just Uninstall JRE and then install JDK, this will solve your error.