Reputation: 6791
Dev env: Scala 2.11.8, JDK 1.8.112 x64, Windows 7 x64.
Problem: Scala still sees the previous JDK 1.8.101 instead of the new one 1.8.112.
C:\Users\myUserName>java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
C:\Users\myUserName>scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_101).
Type in expressions for evaluation. Or try :help.
scala> System.getProperty("java.version")
res3: String = 1.8.0_101
The reason is the new JDK is installed in C:\Program Files\Java\jdk1.8.0_112
while the previous JDK is in C:\Program Files\Java\jdk8
. JAVA_HOME = C:\Program Files\Java\jdk8. So I suppose this is why Scala sees the previous version. However, PATH
C:\Users\myUserName>PATH
PATH=C:\ProgramData\Oracle\Java\javapath;
... etc...
C:\Program Files (x86)\scala\bin;C:\Program Files\Java\jdk8\bin;
C:\ProgramData\Oracle\Java\javapath contains java.exe which comes from the newest JDK. This is why java -version at the command line show the latest JDK.
Question: On Windows, how to make the latest JDK the official JDK? And generally, what is the recommended practice to update JDK on Windows?
Upvotes: 0
Views: 314
Reputation: 14141
The java
command executes java.exe
file from the first folder of the PATH
environment variable where this file is found.
On the other hand scala
command executes scala.bat
batch file and this file set the java environment for scala by JAVA_HOME
environment variable if it exists.
The problem is that in almost every system is the file java.exe
in many different folders - some of them may be subfolders of other program folders (i. e. from Adobe or JetBrains products) which you had installed previously.
The file name is the same but versions may be (and in most cases are) different.
And the recommended practice for upgrading? Install and pray (Oracle itself has problems with it) or install and then manually adjust every application which depends from Java.
Upvotes: 1