Switch JDK version in Windows 10 cmd

前端 未结 4 1107
北恋
北恋 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 10:20

    I created scripts for every version of Java that I have installed on my PC, and use those whenever I need to change the Java version through the command line. Here is an example of one, should be self-explanatory really:

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

提交回复
热议问题