At my work I have user access with no admin privileges. My environment variable points to an old JDK at the current path: C:\ProgramData\Oracle\Java\javapath
From what I read on different posts such as this which states that all user variables override the environment variable except the PATH variable in which it concatenates the environment variable and user variable together. I have followed many different tutorials and currently have my variables set up like this in my user PATH variable.
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_79
JRE_HOME = C:\Users\316830207\jre7
PATH = C:\Users\316830207\AppData\Roaming\npm;C:\Users\316830207\AppData\Roaming\jdk1.7.0_79\bin
TMP = %USERPROFILE%\AppData\Local\Temp
If you notice my PATH variable for the user has npm path as well as jdk. The npm path was added so I could bower from the command line. That works! However the path for the JDK is never used. No matter what when I type java -v I get
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
Since the path variable contacts the only thing I can think of is it skips my JDK path or overwrites. I have tried using command line using setx as I cannot use setx /M as I do not have admin access. I have searched for a few days now and the only conclusion is I am doing this wrong or security from my work is stopping me to overwrite JDKpath.
So my question is am I setting the JDK path incorrectly? Is there a different way I can set it? Why will it only use my environment path and not my user JDK path?
JAVA_HOME contains the installation path of JAVA.
Set environment variable JAVA_HOME to installation path C:\Program Files\java\ jdk-1_7_0_08 using following steps for windows user
1. Right Click on My Computer->Properties-> Advanced->Environment Variables ->User Variables -> New
2. Set JAVA_HOME to value C:\Program Files\java\ jdk-1_7_0_08
Related
I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable.
When I try to run simple java program I get error as
"The system cannot find the file C:\spl\java\bin\bin\java.exe".
The above path contains extra bin.
Where as environment variable and JAVA_HOME has C:\spl\java\bin\ this path.
I cannot understand from where this extra bin directory is coming.
Please help.
From where does system is taking C:\spl\java\bin\bin\ this path?
Your JAVA_HOME should point to the ...\Java\jdk1.8.. directory.
In Your path you should have %JAVA_HOME%\bin.
Some applications refer to JAVA_HOME and add \bin on their own, so you must not add \bin to your JAVA_HOME. Otherwise, you'll receive correct error saying, that C:\spl\java\bin\bin\ doesn't contain Java.exe
Solution:
Remove \bin from your JAVA_HOME
It is quite clear from your example: the system is taking %JAVA_HOME% as the "home" of your java installation, not its bin directory. So when you try to start java.exe, it looks in %JAVA_HOME%\bin. Just remove the bin part of your JAVA_HOME.
I am trying to put the JAVA JDK path into the Windows PATH environment variable.
I changed/inserted the appropriate variables and got the command javac to be working yesterday, but when I tried the same thing today, I am getting the command not recognized error.
Here are the values of the relevant variables (on a fresh cmd instance):
>> echo %JAVA_HOME%
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_101
>> echo %PATH%
C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin;C:\Users\anmol\AppData\Local\Programs\Python\Python35\Scripts\;C:\Users\anmol\AppData\Local\Programs\Python\Python35\;C:\Users\anmol\AppData\Local\Programs\Python\Launcher\
I tried to avoid the spaces present in 'Program Files' by writing JAVA_HOME=C:\Progra~1\Java\jdk1.8.0_101, but the error persisted.
Also, if I open a cmd and type set path=%JAVA_HOME%\bin;%path% and then in the same session type javac, it is recognized correctly.
Can anyone tell what is going on and how to set the PATH correctly?
You have modified PATH with the set command, which applies the changes to the current terminal. To make it a persistent system wide setting, use setx instead.
You'll need both, PATH and JAVA_HOME in the system environment.
Note that ` does not modify the current terminal's environment settings:
NOTE: 1) SETX writes variables to the master environment in the registry.
2) On a local system, variables created or modified by this tool
will be available in future command windows but not in the
current CMD.exe command window.
What has happened in your case? You have set the PATH environment variable at a time where JAVA_HOME was not known yet. In that case, %JAVA_HOME% becomes part of PATH literally. The following example demonstrates that:
C:\>set X=%A%
C:\>set A=something
C:\>set X
X=%A%
C:\>set B=something
C:\>set X=%B%
C:\>set X
X=something
To fix it, set JAVA_HOME using setx, close the terminal and open a new one. Then use setx to set PATH, close the terminal and open a new one.
or
set JAVA_HOME using setx, set JAVA_HOME using set to update the console. Then use setx to set PATH, close the terminal and open a new one.
As depicted in above image java home is set and is being echoed but when i check for version it gives me latest version.
Already restarted the command prompt after setting env variable.
OS is Windows 7
Update:
Following is the Path.
..ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;;%JAVA_HOME%/bin;
I had the same trouble and I solved it with the following steps:
You need the correct environment variables.
To be exactly correct, you only need to set the Path variable.
You need to find where you add %JAVA_HOME%\bin to the path.
Put it at first place in the Path variable:
%JAVA_HOME%\bin;...
where ... represents all other values of Path.
I assume that JAVA_HOME is defined as a variable and had the correct value.
After this reopen console and check:
java -version
JAVA_HOME is environment variable that various application reads in their launcher script
when you invoke java it looks up for all paths specified in your env variable named PATH and wherever the first match is it gets picked up
so if you like command prompt to refer to jdk 6's Java append the path to PATH
You need to add the path to jJAVA_HOME%/bin directory in the path variable too. java command is located in %JAVA_HOME%/bin
Check your PATH environment variable also. Your system is referring to latest Java installation through PATH variable.
I think in your path variable you have hardcoded the path to bin folder. it should always be %JAVA_HOME%/bin.
So that it can pick path from JAVA_HOME variable and you don't need to change both the variables every time.
i am relatively new to java. when i installed jdk and jre on my laptop it asked me to set a system variable with the name path and a value of its home directory. next i installed tomcat server and that too asked me to set CATALINA_HOME,JAVA_HOME and path as its home directory.now after mysql installation it also said a variable of path with its home directory value.will it not effect the old s/w if i change path variable to new software variable address?? or should i create new paths for each software??
CATALINA_HOME and JAVA_HOME are separate variables and should be set separately.
As for the PATH, this is one variable and should contain all necessary values separated by the ; character.
I been trying to set the Maven environment variable, but it's not liking it. I don't know why, I've triple checked everything and it should be working.
Here is the error I got:
ERROR: JAVA_HOME not found in your environment variable.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
And here are my variables:
JAVA_HOME ---> C:\Program Files\Java\jdk1.6.0_26
MAVEN_HOME ----> C:\Program Files\Maven\apache-maven-3.0.5
Path ----> C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;%JAVA_HOME%\bin;%MAVEN_HOME%\bin
Sorry if my path file is a little long. Basically the important part is that I did indeed put them in right, they should both be at the very end. What else could have gone wrong?
Also to clarify a little bit, I did check that the file is indeed where I specify it to be. And I know my Java version should be right, when I do a:
javac -version
in cmd I do get the right version.
Try using M2_HOME instead of MAVEN_HOME in the path and environment variable
M2_HOME ----> C:\Program Files\Maven\apache-maven-3.0.5
and %M2_HOME%\bin in path
As you are using a jdk/maven path with space in between so try using the path in quotes such as :
"C:\Program Files\Java\jdk1.6.0_26"
Or
simply dump the java and maven in non-space directories as it avoids such problems. I generally put java in C:\Java\jdk1.6.0_26 and mavin in C:\maven\maven3.0.
Try either of the solutions and you should get lucky :-)
And please ensure to put the JAVA_HOME environment variable inside the system environment variables and not the user environment variables.
Don't forget to restart your shell after you changed environment variables.
If you are using eclipse then set VM arguments in JRE as
-Dmaven.multiModuleProjectDirectory=true