Switch JDK version in Windows 10 cmd

前端 未结 4 1104
北恋
北恋 2021-02-04 09:32

Is there a way to change JDK version easily in cmd? like the version on mac. Change Default JDK on Mac.

4条回答
  •  情书的邮戳
    2021-02-04 10:25

    Create a folder (in my case it is in C:\devenv) and create a batch file and name it after the version (jdk8.bat, jdk9.bat, jdk10.bat, jdk11.bat etc..) then add this commands. You just need to change the set JAVA_HOME to the location of the jdk version. Add the location of the batch files (C:devenv) to the path on the environment variables

    @echo off
    set JAVA_HOME=C:\Program Files\Java\jdk-11.0.9
    set PATH=%JAVA_HOME%\bin;%PATH%
    @echo Display Java Version
    java -version
    

    You can run it on cmd by just typing the batch name (e.g jdk11)

提交回复
热议问题