Background:
My system variables (JAVA_HOME, path, CLASS_PATH) all were pointing to JDK 1.6 folder whereas when I run "java -version" it shows me 1.8. I have explicitly installed both 1.6 and 1.8 based on software need where 1.6 was the active one for my project and 1.8 was to run ZAP (Zed Attack Proxy) for vulnerability testing. I assumed, JAVA_HOME might have over-written by 1.8 JRE installation and I can change the value back to 1.6 when I am done with ZAP. Unfortunately that's not the case.
After an hour or so digging, it seems that 1.8 installation created folder in location "C:\ProgramData\Oracle\Java\javapath" which had three soft links ('java.exe', 'javaw.exe', 'javaws.exe'). I opened the soft link properties (right mouse click on java.exe), went to tab Shortcut where Target: was pointing to location where 1.8 was installed.
So the possible fixes could be considered are -
My system variables (JAVA_HOME, path, CLASS_PATH) all were pointing to JDK 1.6 folder whereas when I run "java -version" it shows me 1.8. I have explicitly installed both 1.6 and 1.8 based on software need where 1.6 was the active one for my project and 1.8 was to run ZAP (Zed Attack Proxy) for vulnerability testing. I assumed, JAVA_HOME might have over-written by 1.8 JRE installation and I can change the value back to 1.6 when I am done with ZAP. Unfortunately that's not the case.
After an hour or so digging, it seems that 1.8 installation created folder in location "C:\ProgramData\Oracle\Java\javapath" which had three soft links ('java.exe', 'javaw.exe', 'javaws.exe'). I opened the soft link properties (right mouse click on java.exe), went to tab Shortcut where Target: was pointing to location where 1.8 was installed.
So the possible fixes could be considered are -
- Remove 'javapath' folder and rely on system variables (JAVA_HOME, path, CLASS_PATH)
- Cons: every time you need to switch from one version to another, all variables need to be updated carefully, little bit time consuming
- Create shortcut in "C:\ProgramData\Oracle\Java\javapath" to appropriate java
- Pros: takes less time to switch version
Assumption:
- "C:\ProgramData\Oracle\Java\javapath" location is set in the path system variable
Note:
- In some cases with similar behavior, always check the system path, that might have hard or soft link to java.exe. Like, 'c:\windows\system32' might have a different java.exe present which may not be the expecting one