Windows ignores JAVA_HOME: how to set JDK as default?

前端 未结 14 2824
感动是毒
感动是毒 2020-11-27 11:30

How do I persuade Windows to use the JDK instead of a JRE?

This question has been asked before, here and elsewhere:

How do I set the default Java installatio

相关标签:
14条回答
  • 2020-11-27 12:13

    In my case I had Java 7 and 8 (both x64) installed and I want to redirect to java 7 but everything is set to use Java 8. Java uses the PATH environment variable:

    C:\ProgramData\Oracle\Java\javapath

    as the first option to look for its folder runtime (is a hidden folder). This path contains 3 symlinks that can't be edited.

    In my pc, the PATH environment variable looks like this:

    C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Program Files\Java\jdk1.7.0_21\bin;

    In my case, It should look like this:

    C:\Windows\System32;C:\Program Files\Java\jdk1.7.0_21\bin;

    I had to cut and paste the symlinks to somewhere else so java can't find them, and I can restore them later.

    After setting the JAVA_HOME and JRE_HOME environment variables to the desired java folders' runtimes (in my case it is Java 7), the command java -version should show your desired java runtime. I remark there's no need to mess with the registry.

    Tested on Win7 x64.

    0 讨论(0)
  • 2020-11-27 12:13

    There's an additional factor here; in addition to the java executables that the java installation puts wherever you ask it to put them, on windows, the java installer also puts copies of some of those executables in your windows system32 directory, so you will likely be using which every java executable was installed most recently.

    0 讨论(0)
  • 2020-11-27 12:14

    In Windows 8, you may want to remove C:\ProgramData\Oracle\Java\javapath directory.

    from path

    It solved my issue.

    0 讨论(0)
  • 2020-11-27 12:14

    This issue is probably because of the earlier versions of Java installed in your System. First check your Environment Variables Carefully and remove all the Environment Variables related to the previous versions of JAVA and replace those paths to

    C:\Program Files\Java\<your new jdk version>\bin
    
    0 讨论(0)
  • 2020-11-27 12:17

    I have this issue too. I am running 1.6 but want to build the code I'm working on with 1.5. I've changed the JAVA_HOME and PATH (both user and system) to no avail.

    The answer is that the installer for 1.6 dropped java.exe, javaw.exe, and javaws.exe into my Windows\System32 folder (Windows 7).

    I solved it by renaming those files to java_wrong.exe, javaw_wrong.exe, and javaws_wrong.exe. Only after doing that does it pick up the correct version of java as defined in JAVA_HOME and PATH. I renamed the files thusly because that deleted them in an easily reversible manner.

    Hope this helps!

    0 讨论(0)
  • 2020-11-27 12:18

    For my Case in 'Path' variable there was a parameter added like 'C:\ProgramData\Oracle\Java\javapath;'. This location was having java.exe, javaw.exe and javaws.exe from java 8 which is newly installed via jdk.exe from Oracle.

    I've removed this text from Path where my Path already having %JAVA_HOME%\bin with it.

    Now, the variable 'JAVA_HOME' is controlling my Java version which is I wanted.

    0 讨论(0)
提交回复
热议问题