I\'m in the situation where I\'ve installed the JDK, but I can\'t run applets in browsers (I may not have installed the JRE).
However, when I install the JRE, it clo
I simply install all the versions of JDK I need and the latest installed becomes default, so I just reinstall the one I want to be default if necessary.
Stacked by this issue and have resolved it in 2020, in Windows 10. I'm using Java 8 RE and 14.1 JDK and it worked well until Eclipse upgrade to version 2020-09. After that I can't run Eclipse because it needed to use Java 11 or newer and it found only 8 version. It was because of order of environment variables of "Path":
I suppose C:\Program Files (x86)\Common Files\Oracle\Java\javapath
is path to link to installed JRE exe files (in my case Java 8) and the issue was resolved by move down this link after %JAVA_HOME%
, what leads to Java 14.1/bin folder.
It seems that order of environment variables affects order of searched folders while executable file is requested. Thanks for your comment or better explanation.
After many attempts, I found the junction approach more convenient. This is very similar on how this problem is solved in linux.
Basically it consists of having a link between c:\tools\java\default
and the actual version of java you want to use as default in your system.
PATH
pointing to ONLY to this jre c:\tools\java\default\bin
- JAVA_HOME
pointing to `c:\tools\java\defaultC:\tools\Java\JRE_1.6
C:\tools\Java\JRE_1.7
C:\tools\Java\JRE_1.8
C:\tools\Java\
junction default JRE_1.6
This will create a junction (which is more or less like a symbolic link in linux) between C:\tools\java\default
and C:\tools\java\JRE_1.6
In this way you will always have your default java in c:\tools\java\default
.
If you then need to change your default java to the 1.8 version you just need to execute
junction -d default
junction default JRE_1.8
Then you can have batch files to do that without command prompt like
set_jdk8.bat
set_jdk7.bat
As suggested from @СӏаџԁеМаятіи
mklink /J default JRE_1.8
Need to remove C:\Program Files (x86)\Common Files\Oracle\Java\javapath from environment and replace by JAVA_HOME which is works fine for me
I have patched the behaviour of my eclipse startup shortcut in the properties dialogue
from
"E:\Program Files\eclipse\eclipse.exe"
to
"E:\Program Files\eclipse\eclipse.exe" -vm "E:\Program Files\Java\jdk1.6.0_30\bin"
as described in the Eclipse documentation
It is a patch only, as it depends on the shortcut to fix things...
The alternative is to set the parameter permanently in the eclipse initialisation file.
an alterable way to run an .jar app is create an .bat cmd for it. for example, you have jre10 and jre8 installed on your pc,and jre10 is your default jre. but your jar is specified to work with jre8,following cmd will work:
"C:\Program Files\Java\jre1.8.0_181\bin\java.exe" -jar JabRef-4.3.1.jar