I installed java before and i am running java applications on Centos, it is located at /usr/bin/java.
For some other reason i want to install it to another location, let's say /myDirectory/java
I downloaded java jdk as tar file and extract it to /myDirectory this directory then i set JAVA_HOME accordingly.
The problem is i can't start the applications anymore, the log says :
ERROR: JAVA_HOME is set to an invalid directory: /myDirectory/jdk1.8.0_181/bin/java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Is it because i had a prior installation? How do i achive this?
Any help would be aprreciated, thanks.
ERROR: JAVA_HOME is set to an invalid directory: /myDirectory/jdk1.8.0_181/bin/java
Your error suggests you set JAVA_HOME to the path of the java binary, but JAVA_HOME must point to the JDK directory, not the binary, i.e. JAVA_HOME=/myDirectory/jdk1.8.0_181, without /bin/java.
Related
I have JAVA_HOME set in the necessary system environments, but the VScode plugin IBM Z Open Editor gives me this error:
Your "JAVA_HOME" environment variable does not specify a valid file path. Please verify that (1) The path does not end in "/bin/java". (2) The path points to a 64-Bit Java. (3) The path points to the correct location in the file system.
(From what I can see) I have all three of these points the error is pointing to. Any help is appreciated.
Type java --version in Command Prompt to check if you installed JDK11 or recent version, also 64-Bit. If not, reinstall the correct one:
Reference:
Installing a Java Development Kit (JDK)
To Install the JDK Software and Set JAVA_HOME on a Windows System
The settings about JAVA_HOME in VS Code should be:
"java.home": "C:\\Users\\...\\AppData\\Local\\Programs\\AdoptOpenJDK",
Which you can also configure it by opening Command Palette(Ctrl+Shift+P) then choosing the option: Java: Configure Java Runtime
The installed JDK which is JDK11 or recent version should be displayed in the list and you can choose the one you wanted, which is equal to manually setting java.home in Settings.json.
If you can't see the installed jdk in the list, turn to the referenced link to check if JAVA_HOME in Environment Variables is set correctly.
I am trying to install Apache Ant on my system, while setting the path variable. I have jdk installed on my system. I set the ANT_HOME environment variable to where ant is located on the system, i.e, F:\apache-ant-1.9.6\, and the path variable to F:\apache-ant-1.9.6\bin.
But when I test if ANT is installed correctly by typing ant -version on cmd , I get this error:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.
0_25\lib\tools.jar
Apache Ant(TM) version 1.9.6 compiled on June 29 2015
While reading this answer, they say tools.jar in included in jdk and not jre. But I have correctly installed jdk, and set the environment variable correctly for that too.
When you actually go to the location specified by ant build it'll not have tools.jar.
The error is misleading and wrong. It is just because either JAVA_HOME is not defined or not set properly. Once it is done, error would get resolved.
I was also facing same issue but after research of an 1 hour I got a solution.
In system variable set your jdk path in starting.
Variable name: Path
Variable value: C:\ProgramFiles\Java\jdk1.8.0_45\bin;C:\Users\SESA401780\AppData\Local\Android\sdk\build-tools;C:\Users\SESA401780\AppData\Local\Android\sdk\tools;...
Enter Ok Ok ... and
Open new cmd
You are most likely missing the JAVA_HOME environment variable. It looks like the java.exe you are running from the command line is finding your JRE, not your JDK. Set JAVA_HOME to the location of your JDK, and move the bin directory of your JDK to be before the JRE in your PATH and try again, should work.
As the error message says:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.
0_25\lib\tools.jar
tools.jar is expected to be in C:\Program Files\Java\jre1.8,
but it's not there.
That path looks suspiciously like a JRE path,
not a JDK.
Make sure to set JAVA_HOME to the path of your JDK. Then it should work.
It seems that currently JAVA_HOME is pointing to the path of the JRE,
not the JDK.
As mentioned in Question Title, I am unable to open Android Studio.
When I am trying to open it, below message is shown:
"The environment variable JAVA_HOME (with the value of
C:\Program Files\Java\jdk.1.8.0_31\bin;) does not point
to a valid JVM installation."
How can I solve this problem?
Try removing \bin from the end of your JAVA_HOME system variable.
Your path variable for Java Installation is probably corrupt maybe due to a re-install or you didn't set it in the first place.
This can be easily fixed.
First install the latest version of JAVA SE from this webpage.
To set the temporary path of JDK (in windows), you need to follow following steps:
Open command prompt
copy the path of jdk/bin directory under program files. note it's "jdk" not "jre".
write in command prompt: set path=*copied_path*
For Example:
set path=C:\Program Files\Java\jdkx.x.x_23\bin
where x.x.x are the jdk version related number
It is useful to set the PATH environment variable permanently so it will persist after rebooting. You can read more about how to do this over here: Set PATH and CLASSPATH
I have recently downloaded Maven and followed the instructions given on this this page. I already have ant installed on my machine.
Now, if I want to verify that Maven is installed perfectly or not it is giving me error that JAVA_HOME is not set correctly, but same works perfectly fine for ANT.
For Maven I tried :
1. open cmd
2. type mvn -version
3. Error appeared :
C:\Users\Admin>mvn -version
ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jre7\bin"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
For ANT I tried and worked :
1. open cmd
2. type mvn -version
3. Apache Ant(TM) version 1.9.1 compiled on May 15 2013
I went to the directory to check that java.exe is actually there in that directory or not and it was there. I checked the environment variables they set fine. I restarted the system and checked again but same problem. Please let me know what am I missing.
JAVA_HOME should point to jdk directory and not to jre directory. Also JAVA_HOME should point to the home jdk directory and not to jdk/bin directory.
Assuming that you have JDK installed in your program files directory then you need to set the JAVA_HOME like this:
JAVA_HOME="C:\Program Files\Java\jdkxxx"
xxx is the jdk version
Follow this link to learn more about setting JAVA_HOME:
http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html
Do not include bin in your JAVA_HOME env variable
Follow the instruction in here.
JAVA_HOMEshould be like this
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07
JAVA_HOME = C:\Program Files\Java\jdk(JDK version number)
Example: C:\Program Files\Java\jdk-10
And then restart you command prompt it works.
Just remember to add quotes into the path if you have a space in your path to java home.
C:\Program Files\java\javaxxx\ doesn't work
but
"C:\Program Files\java\javaxxx\" does.
The JAVA_HOME should point to the JDK home rather than the JRE home if you are going to be compiling stuff, likewise - I would try and install the JDK in a directory that doesn't include a space. Even if this is not your problem now, it can cause problems in the future!
You are pointing your JAVA_HOME to the JRE which is the Java Runtime Environment. The runtime environment doesn't have a java compiler in its bin folder.
You should download the JDK which is the Java Development Kit. Once you've installed that, you can see in your bin folder that there's a file called javac.exe. That's your compiler.
JAVA_HOME should point to jdk directory like in the image with new variable, like below
PATH should point to jdk bin like below
Run the below command in your terminal and restart it.
> set JAVA_HOME="C:\Program Files\Java\jdk-xx.xx"
xx.xx is the java version
I am programming through java 1.6 u_17, but i have JRE version 6 and JRE version 7 installed, so how to run my compiled program from JDK 1.6 to run through the JRE 6 only?
By Default, it runs my class files through JRE 7, how to change this behavior? Any idea of setting Class path in windows 7, as we does it for JDK.
The following is shown in my command prompt
E:\JAVA>javac -version
javac 1.6.0_17
E:\JAVA>java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)
This is for my SET command showing the Windows 7 environment paths
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Administrator\AppData\Roaming
ClassPath=C:\Program Files\Java\jdk1.6.0_17\bin\mysql-connector-java-5.1.5-bin.jar;
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=RANDMATE-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Administrator
JAVA_HOME=C:\Program Files\Java\jre6\bin;
LOCALAPPDATA=C:\Users\Administrator\AppData\Local
LOGONSERVER=\\RANDMATE-PC
NUMBER_OF_PROCESSORS=2
OS=Windows_NT Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.6.0_17\bin;C:\Program Files\Java\jre6\bin;C:\Program Files\MyS
QL\MySQL Server 5.1\bin;C:\Program Files\UltraEdit\;C:\Program Files\Jar2Exe Wizard\;C:\Program Files\Java\jre6\bin;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 6 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0605
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\ADMINI~1\AppData\Local\Temp
TMP=C:\Users\ADMINI~1\AppData\Local\Temp
USERDOMAIN=RANDMATE-PC
USERNAME=Administrator
USERPROFILE=C:\Users\Administrator
windir=C:\Windows
Looks like you are using Windows. Please go the Environment Variables and define a user variable as:
Right Click(My Computers) -> Advanced -> Environment Variables -> Add
Variable Name = JAVA_HOME
Variable Value = Root Folder of Java 1.6.0_17 installation
Also in the same screen, please check the PATH variable and make sure **bin** Folder of Java 1.6.0_17 installation is added in the path preferably in the beginning and remove the Java 7 from the path, if it is there.
I fix this problem by removing the java.exe in system32 folder. And then in the cmd the java command refer to the jdk set in the path enviroment variable.
java.exe is also available in C:\windows\system32 and in your case its version might be 1.7..
Since your path has C:\windows\system32 first. no matter how to set rest of the path, sonar always will load jre7. (refer to conf\wrapper.conf in Sonar directory, by default it has wrapper.java.command=java)
To fix this, change following property of the "wrapper.conf" file
wrapper.java.command=C:\Program Files\Java\jdk1.6.0_XX\bin\java
this will fix the issue irrespective of the path variables.
For those who had the same problem I suggest reading this thread:
https://superuser.com/questions/479889/wrong-java-version-being-reported
Quote of wmz: "To check what actually executes when you run 'java -version' run from command line:
for %I in (java.exe) do #echo %~$PATH:I"
Windows is checking the PATH variable to find an executable named java and using that to launch your application. It is quite normal in a development environment to have many installations (as you do). However this calls on you to manage your environment.
There are two ways for you to set environment variables in Windows. By going to My Computer > Advanced Settings > Environment Variables as described above, you can set a variabler to your JDK installation and then update the Path to find the bin directory in that installation. Youy have the choice of updating System variables (all users) or user variables (your account only).
Personally, I prefer not to use the system/user environment variables as this provides less flexibility. You can use bat files to explicitly set the Path for a specific moment in time, or indeed to override the JAVA_HOME to point to a different installation.
If you are using an IDE you can usually specify the target runtime on a per project basis. Alternatively, when running the program, provide the fully qualified path to the version of the java executable you wish to use.
I had same problem. Issue is that Java installation will copy a java.exe, javaw.exe and javaws.exe to windows/system32 directory. You must have installed JDK7 recently.
I just removed those files from Windows/System32 directory, however, kept older version in path. This solved the issue.
Try it out.
I was facing the similar problem. I am using Java 7 and Java 8 together. The Java 8 was installed in the machine but the 7 set-up I copied from another system. I have already set the JAVA_HOME & path pointing to 7. But when I try to echo %path%, it shows the Jdk 8 in the class path. after lots of google, I have found "C:\ProgramData\Oracle\Java\javapath" in the path. Removing the line from the path solved the problem.
Background
I'm using Windows 8.1 and I have both JDK6 and JDK8 installed. For development purpose, I needed to get java version "1.6.0_45" over the command java -version and javac 1.6.0_45 over javac -version. The second command was working as expected after setting JAVA_HOME as Home folder of JDK6 and adding %JAVA_HOME/bin% in Path. However the first command was still returning java version "1.8.0_71"
Troubleshooting
I could find the an entry in the Path environment variable which points to C:\ProgramData\Oracle\Java. This folder actually contains short cut to java.exe of JDK8.
Proper solution: Uninstall JDK 8
Workaround:Edit the short cut file so that it points towards java.exe inside %JAVA_HOME%\bin (Please replace the variable with actual folder)
set the PATH variable to your jdk6\bin directory. so that it will pick the javac and java from jdk6.
for setting the path variable go to Environment Variables.
After setting the path variables you need to restart your command prompt. (NOT the computer).
Just right click on MyComputer, then Advanced System Settings-->Environment Variables-->New
Then in the "variable Name" text field add the string "PATH" or if it already exists select PATH from the list and click edit then append the path for "bin" folder in java in program files to the Variable value text field followed by a semicolon (;), if not exits add the path of bin directory of your java folder in "Variable Value" field and click "OK".
If you want to check the result, open up a command prompt and type "java" then hit enter.
For windows 7(X86) path setting:
first step:
Mycomputer(Right click)-->properties-->advanced settings-->environment variales-->new
(user variable)
on this first varible name: "" JAVA_HOME "" value: "" C:\Program Files\Java\jdk1.7.0_45 ""
second variable name: "" PATH "" value: "" C:\Program Files\Java\jdk1.7.0_45\bin;.; ""
There are two types of path for java : Permanent & Temporary.
Here is the video tutorial describing how to set path for Java?
How to Set path for Java : https://www.youtube.com/watch?v=rM4Qq3Ua7Sk
This video tutorial will guide you in setting permanent and temporary path for Java. Simply follow the steps. This will work with any version of Java, JDK or JRE. In video I have used path of JDK, Simply copy path of JRE instead of JDK and rest is same.
OR read the tutorial here : How to Set path for Java : http://aatul.me/2011/08/24/how-to-set-path-for-java/
Hope this solutions will help you.