At the time of this post (11/19/2019), I downloaded Java JDK version 13.0.1 on my windows 10 machine. After the download, I modified the Path system variable on my machine to include this path "C:\Program Files\Java\jdk-13.0.1\bin" (without double quotes). I then modified my JAVA_HOME system variable to include this path "C:\Program Files\Java\jdk-13.0.1". However, when I type "java -version" at the command prompt, this is what I get.
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
Can someone please explain to me why my current java version from the command prompt is displaying the result above as opposed to java version 13.0.1? Thanks in advance!
Try uninstall old JDK. I don't change anything when I install new JDK and I only choose new JDK within new project.
I have actually 3 versions of JDK.
Try setting the java_home and path using Command prompt.
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0"
setx PATH "%PATH%;%JAVA_HOME%\bin";
Note:
Once you set in command prompt, close and reopen cmd.exe for the changes to reflect.
Have a Happy programming !!! :-)
References:
https://www.codejava.net/java-core/how-to-set-environment-variables-for-java-using-command-line
Related
I am using the 'jshell command in my machine it is not recognised. But java command is working fine. is there any environment setup for jshell in jdk 10
C:\Users\Kannan
λ jshell
'jshell' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Kannan
λ java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
jshell is a part of JDK 10 and it's located in the %JAVA_HOME%\bin folder on Windows.
Possible problems:
You installed JRE 10 only (instead of JDK 10). jshell is NOT part of the JRE.
%JAVA_HOME%\bin is not part of the PATH system variable.
See also: Environment variables for java installation
check if jshell is installed with your Java environment. ls [JAVA-INSTALLEDPATH]/bin
if jshell does not exist download appropriate JDK
if jshell is present append path in your environment profile or use full path.
You need to add the bin folder of your Java Development Kit (JDK) installation to the PATH environment variable. The java command works, because the JRE installs a copy of the java.exe executable in C:\ProgramData\Oracle\Java\javapath\ and adds it to the PATH.
For editing the PATH, see How do I set system environment variables in Windows 10? on superuser
Had the same problem. I set JAVA_HOME and wrapped it with double quotes ("").
JAVA_HOME="C:\Program Files\Java\jdk1.8.0_144"
What you have is a JRE. You should install JDK and set JAVA_HOME. Then jshell will start working properly.
The same problem has happened to me.
Uninstall and Install the right JDK from Oracle website.
steps:
1. Control Panel > System & Security > System > Change Setting > Advance > Change Environment Variable > System Variable > New > Variable Name:"Path" & Variable Value: "C:\Program Files\Java\jdk-10.0.1\bin" (address of the bin)> ok
You are good to go.
Here's the link to the video that helped me.
https://www.youtube.com/watch?v=UokTaTwckDw
Run you command prompt as Administrator. window -> cmd -> Run as Administrator then type jshell.
Remove any default path variable that is set in envirnoment variables when you install JDK apart from JAVA_HOME.Then update your JAVA_HOME to /path of JDK 9 OR Above/
I am trying to upgrade to: Java 8 Update 66, from Java 6, on my Mac running Mac OS X 10.10.5. I downloaded the Java Update .dmg file: re-8u66-macosx-x64.dmg. When I run the installer I get the message it installed properly. When I confirmed the install via the FireFox Browser at this URL:
https://java.com/en/download/installed.jsp
It reports:
Congratulations!
You have the recommended Java installed (Version 8 Update 66).
However, If I open a terminal window and enter: java -version
It reports:
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
Can someone please explain what is going on here? Do I need to update a link somewhere?
Thanks.
Please check your PATH variable, and make sure that the java directories in the path match the directories in your computer. It should be the bin folder of the JAVA_HOME environment directory. Also check that JAVA_HOME environment variable is set to the jdk folder of your java installation.
There's two option based on my experience to fix this issue, fisrt uninstalled the java on your computer and reinstalled using the latest version.
Second, run a different version of Java, either specify the full path, or use the java_home tool:
List your installed java version:
$ /usr/libexec/java_home -V
In this case you are using java 8 so you can run command
$ /usr/libexec/java_home -v 1.8 --exec javac -version
If you want to make easy to switch your java version you can create alias in ~/.bashrc
alias java6="export JAVA_HOME=$(/usr/libexec/java_home -v 1.6);echo 'using Java 6'"
alias java8="export JAVA_HOME=$(/usr/libexec/java_home -v 1.8);echo 'using Java 8'"
Hope it help
Before marking it duplicate FYI I have already read How can I change the Java Runtime Version on Windows (7)? and How to set path for Jre 6 when jre 7 installed?.
I have both Java7 and Java8 in my machine. I have
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_60
PATH = ...;%JAVA_HOME%\bin;....
but I am getting
C:\>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
C:\>javac -version
javac 1.7.0_60
I want to set JRE to 1.7 too. How to do that?
You will probably have to edit your path environment variable.
If you want to check what's in your PATH environment variable in an organized fashion, run:
echo %path:;=&echo.%
Make sure the 1.8 is not on the path or if you want it there make sure it appears after 1.7.
To edit it, go to My Computer > Properties > System Properties > Advanced tab > Advanced section > Environment Variables.
Also check what is actually launched when you run java from the command line, run the following command:
where java
It will show you what windows runs when you request java.
To solve the problem, remove or change the name of java.exe and javaw.exe into System32 folder:
Prepend the System Variable's Path with JRE bin's path.
where java did work for me. I found there is another version of java associated with the SPSS (1.8.0). Uninstall SPSS and the problem solved.
The solution that worked for me was:
In "Path" variable replace "C:\ProgramData\Oracle\Java\javapath;" with %JAVA_HOME%\bin where JAVA_HOME variable was set to "C:\Program Files\Java\jdk1.7.0_60"
I have two javas installed on my pc. jdk1.7.0_45 (x64) and jdk1.6.0_45(x86). I want that default java on my machine would be jdk1.6.0_45(x86). I added JAVA_HOME with value C:\Program Files (x86)\Java\jdk1.6.0_45 and added C:\Program Files (x86)\Java\jdk1.6.0_45\bin to system path, but still when i type in command prompt "java -version" it says:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
I have no idea why the things are like that, because my OS should see jdk1.7.0_45 (x64) version. Why is that so?
I use windows 8
edit:
after setting java home to jdk1.7.0_45 (x64) folder and updating path accordingly javac works, but then I set java home and path to jdk1.6.0_45(x86) javac does not work.
You need to add the %JAVA_HOME%\bin to the very beginning of your path. This is because Java is installed in your %SystemRoot%\system32, too. If you add the %JAVA_HOME%\bin to the beginning of your path the Java installed in your JAVA_HOME will be used.
JAVA_HOME does not help when we run java from command line, you should fix PATH system var
I added JAVA_HOME with value C:\Program Files (x86)\Java\jdk1.6.0_45
In Windows, you should excape spaces in the path: JAVA_HOME="C:\Program Files (x86)\Java\jdk1.6.0_45". But the best way is to set Java to a folder that doesn't have spaces in its path. For example, I use C:\Java\Java6
and added C:\Program Files (x86)\Java\jdk1.6.0_45\bin to system path
Probably you added after path to the Java 7. Make sure that Java 7 doesn't exist in the system path.
I've installed jdk 7 and set up the "JAVA_HOME" to this version. Then, I've installed jdk 6 and I've updated the "JAVA_HOME" to point to jdk 6. After closing and reopening the system, when typing "java -version", I got always :
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode, sharing)
However, when typing
echo %JAVA_HOME%
I got :
C:\Program Files\Java\jdk1.6.0_45
I didn't understand why java -version don't display the value of "JAVA_HOME"
Java 7 puts a java.exe in c:\windows\system32. You could try to delete these exe's, but I'm not sure Windows will allow it, or restore it after a reboot.
If you want to override it, you must put %JAVA_HOME%\bin as first entry in your PATH, before c:\windows\system32.
Which java starts when you run java -version depends on the PATH env variable, not JAVA_HOME. OS will be looking for java.exe (Windows) like for any other program
if you run java on your command window, it takes java from the PATH variable. JAVA_HOME is used my maven etc...
I believe your PATH variable is pointing to JAVA version 1.7.0_40/bin directory.
According to my understanding, this is nothing to do with your JAVA_HOME environment variable. You are getting java version from C:\windows\system32\java.exe.
If you don’t want that behaviour then in system variables section put %JAVA_HOME%\bin as starting element (Of course you should have JAVA_HOME). (I thought of adding image but I dont have enough reputation to do so :( )