2

I run Windows 7 with different JRE/JDKs installed. I try to set the JAVA_HOME path to "C:\Program Files\Java\jdk1.8.0_45". I tried multiple ways to do that like described in How to set java_home on Windows 7?.

I think it worked, because in the advanced System Properties, the new path is shown and the command echo %JAVA_HOME% also returns the new path. But when I invoke the following program via cmd

public class JavaVersionShower {
    public static void main(String[] args){
        JOptionPane.showMessageDialog(null, System.getProperty("java.home"));
    }
}

the message window says "C:\Program Files\Java\jre1.8.0_66". I also cannot use the JavaCompiler API which is only available if the used java version is a jdk.

Community
  • 1
  • 1
Feanor
  • 320
  • 2
  • 11
  • 1
    Do you have different Java installations on your system? – Julian L. Dec 13 '15 at 13:50
  • 1
    did you restart CMD after you changed java home? – AdamSkywalker Dec 13 '15 at 13:56
  • I have different java installations on my system (like I already said in my question) and I did restart the cmd after I changed JAVA_HOME; my java installations are: jdk1.7.0_51, jdk1.8.0_45, jre1.8.0_45, jre1.8.0_60, jre1.8.0_66 – Feanor Dec 13 '15 at 14:52
  • which jre did you run that with? I think "java.home" refers to the installation directory of the jre currently running. Have you tried asking for the system property "JAVA_HOME" from inside Java? – Androbin Aug 22 '16 at 15:19

1 Answers1

0

Updating java home and path is little different in windows 7 and 8. You might need to go to "C:\ProgramData\Oracle\Java\javapath" to update them. This article might be helpful to you Update Java path in Windows 8

Ravi

Ravinder G
  • 36
  • 5