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$//')"
Related
I have the following error building my android project on Ubuntu from the command line using the gradle wrapper. Running from Android Studio is fine. After some reading of other posts I'm still not sure how to fix it, since my JAVA_HOME enviroment variable is correct. I'm not setting it from any user config files but it seems to be set from somewhere on my system. I've also tried uninstall/reinstall.
Execution failed for task
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
So where is JAVA_HOME set to and where is it installed?
user#user$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
user#user$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-amd64
user#user
sudo update-java-alternatives --list
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
At this point I'm lost and confused.
user#user$ readlink -f $(which java)
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
user#user$ which java
/usr/bin/java
user#user$ whereis java
java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
JAVA_HOME isn't set in any of my user config files, the following returns nothing
grep JAVA_HOME /etc/environment /etc/bash.bashrc /etc/profile.d/* /etc/profile
The only environment entries are
user#user$ grep -r JAVA_HOME /etc
/etc/ca-certificates/update.d/jks-keystore: export JAVA_HOME=/usr/lib/jvm/$jvm
/etc/ca-certificates/update.d/jks-keystore: PATH=$JAVA_HOME/bin:$PATH
Ubuntu 18.04
sudo ./teamcity-server.sh run
Java executable of version 1.8 is not found:
- Java executable is not found under the specified directories: '', '/home/alex/TeamCity/bin/../jre'
- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
- Java executable is not found in the default locations
- Java executable is not found in the directories listed in the PATH environment variable
Please make sure either JAVA_HOME or JRE_HOME environment variable is defined and is pointing to the root directory of the valid Java (JRE) installation
Environment variable FJ_DEBUG can be set to enable debug output
Java not found. Cannot start TeamCity server. Please ensure JDK or JRE is installed and JAVA_HOME environment variable points to it.
java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
alex#teamcity-server:~/TeamCity/bin$
$JAVA_HOME (tried default-java, /bin)
-bash: /usr/lib/jvm/java-11-openjdk-amd64: Is a directory
$JRE_HOME (tried default-java, /bin)
-bash: /usr/lib/jvm/java-11-openjdk-amd64: Is a directory
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/bin:/usr/bin:/sbin:/usr/games:/usr/local/games:/usr/lib/jvm/java-11-openjdk-amd64/bin
readlink -f $(which java)
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
Tried
ln -s /usr/lib/jvm/java-11-openjdk-amd64/bin /home/alex/TeamCity/jre
Is it requires SPECIFIC java version and does not work with latest?
Did i set variables incorrectly?
I guess, TeamCity is expecting a Java 1.8
Java executable of version 1.8 is not found.
But you are feeding it with a Java 10
openjdk version "10.0.2"
The I think the answer to
Is it requires SPECIFIC java version and does not work with latest?
is "Yes.", it requires Java 1.8 only, maybe.
You run server under sudo. Set $JAVA_HOME for root too - I guess, it set only for your user.
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)
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
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.