Switching to java 11 from java 8

后端 未结 4 1854
误落风尘
误落风尘 2021-01-05 01:55

I have downloaded and installed oraclejdk11 from oracle official site and modified PATH & JAVA_HOME variable in system environment variable on windows

C:\\Users\

4条回答
  •  庸人自扰
    2021-01-05 02:29

    The JDK includes the JRE which you can launch by using the java executable in the bin folder. You use this executable just like any other executable.

    When you type java in the command line it is actually shorthand. It searches your PATH until it finds the first matching java executable. If you want to specify a different java executable you can give the absolute path to the executable.

    C:\Users\Avril> "C:\Program Files\Java\jdk-11.0.1\bin\java" -jar path\to\file.jar
    

    You may be wondering, if you've set JAVA_HOME and PATH to point to JDK-11, why does java -version still use Java 8?

    Take a look at your PATH and you'll likely find something like C:\ProgramData\Oracle\Java\javapath as one of the first entries (see this). This entry was added automatically when you installed Java 8 and points to the Java 8 executables (java, javaw, and javaws). Since it's before your %JAVA_HOME%\bin entry, it takes precedence. However, ...\javapath doesn't contain javac and that's why javac -version used JAVA_HOME (Java 11).

提交回复
热议问题