This question already has answers here:
JAVA_HOME is set to an invalid directory:
(20 answers)
Closed 4 years ago.
I am facing the issue while I build the android. I installed java jdk properly.
In path variable you have to give the both JDK and JRE path upto bin,
like this
path : ....;C:\Program Files\Java\jdk1.8.0_181\bin;C:\Program Files\Java\jre1.8.0_181\bin;
coming to JAVA_HOME give the path upto JDK folder
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_181
u have given upto bin may be that's the issue.
If your cmd is open then close and open new cmd and do the operations
Thank you
Related
This question already has answers here:
JAVA_HOME is set to an invalid directory:
(20 answers)
Closed 6 months ago.
I am trying to run a React native app with this command
npx react-native run-android --variant=stagingDebug --appId com.ursafe_staging
But getting this wrong environment path error
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_202\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installStagingDebug -PreactNativeDevServerPort=8081
Here is my environment path looks like
and this one
Still getting the error when I run the command.
JAVA_HOME shouldn’t point to the bin directory. It should point to the JDK installation path.
It should be: C:\Program Files\Java\jdk1.8.0_202, also you don't need JRE if you already have %JAVA_HOME%\bin, see https://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux
This question already has answers here:
Maven JAVA_HOME environment variable is not defined correctly, but it is
(1 answer)
How do I fix maven error The JAVA_HOME environment variable is not defined correctly?
(31 answers)
Closed 1 year ago.
enter image description here
Tried all the steps provided in Maven JAVA_HOME environment variable is not defined correctly, but it is
Tried by pointing jdk to 1.8 version, issue still exist
enter image description here when we run java version in cmd after pointing to 1.8, it's giving version 15
In IntelliJ IDEA go to File>Project Structure>SDK>JDK home path. Copy it and then go to My Computer>Advanced Settings>Environment Variables Change the JAVA_HOME path to what you have copied. Then open new cmd, and try mvn -v
This solution worked
enter image description here
This question already has answers here:
JAVA_HOME should point to a JDK not a JRE
(25 answers)
Closed 4 years ago.
Hello and thank you for any help you can provide.
I just upgraded to Ubuntu 18.04.1 and before the install my JAVA_HOME for my path was defined properly and worked successfully. However, I am now unable to use Maven due to the following error: "JAVA_HOME should point to a JDK not a JRE". I know this is a common problem and I tried a lot of potential solutions before making this post.
When I echo $JAVA_HOME, I get back /usr/lib/jvm/java-11-openjdk-amd64/bin which is what I set it to be in my .bashrc via the following lines:
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH
From there, I also checked Which java where I got the output of /usr/bin/java. I checked further and found that readlink -f /usr/bin/java returns a value of /usr/lib/jvm/java-11-openjdk-amd64/bin/java. Again, this points to a JDK not a JRE.
I also attempted to fix the issue by configuring a java with sudo update-alternatives --config java and chose the value of /usr/lib/jvm/java-11-openjdk-amd64/bin/java
To top it all off, I have reinstalled java and maven and I have restarted my computer and command line multiple times.
First, try and remove the /bin from your JAVA_HOME path.
You should reference the main folder of the JDK, not its bin/ subfolder.
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
This question already has answers here:
Ubuntu: change the path from OpenJDK 6 to Oracle JDK 7
(5 answers)
Closed 6 years ago.
I am trying to uninstall Oracle jdk 8 on my Ubuntu 14.04 server, in order to replace it with open jdk 8 because open source ftw. I have run apt-get purge, apt-get autoclean, logged out, logged back in, and when I run the env command, I see the following:
JAVA_HOME=/usr/lib/jvm/java-8-oracle
I do not want to overwrite this value in my .bashrc file, I do not want to take shortcuts or apply band aids, I want to fix the problem at the source by finding where it is set and removing it. Please help
I found the solution. I ran the following command to find files with the old jdk path:
sudo find / -type f -exec grep -Flm 1 '/usr/lib/jvm/java-8-oracle' {} +
The culprits were in the following directory:
/etc/profile.d
This question already has answers here:
Get path to java JRE
(3 answers)
Closed 9 years ago.
I am wondering if there is a way, from java, to find the location of the java.exe running the program?
My use case is that I am trying to have Java execute a batch script that needs JAVA_HOME to be set in the local environment. The environment that I am executing this on may not have JAVA_HOME set or even the java executable on the path, but I would assume that the JVM knows where its executable is located.
System.getProperty("java.home");
is one option. Which shows the following directory in my machine:
C:\Program Files\Java\jdk1.7.0_02\jre
Most important system properties are listed here.
The java.home property will supply the path to the currently running JRE, regardless of what is installed, or what JAVA_HOME is. See the Oracle documentation here.
System.getProperty("java.home");