Playing with JShell to realize the use of multiple jdk switching

notes

The Java Shell Tool (JShell) is an interactive tool for learning the Java programming language and prototyping Java code. This tool uses the command line to run. The premise is that you need to download jdk9 and above, so today I will share the tutorial of switching jdk by myself.

insert image description here

Finished product demo (to achieve the same smoothness as py)

insert image description here

process

Download JDK

https://www.oracle.com/java/technologies/downloads My computer is equipped with relatively stable jdk8 and jdk9 (it should be noted here that you must be optimistic about the system and number of digits of your computer and choose the appropriate jdk, otherwise you will no follow up)


insert image description here

Configure environment variables

  • open my computer
  • Click System Advanced Settings
  • Set up a home for the two jdk respectively. The installation path of jdk is behind it, and you can copy it to the bin directory.
    insert image description here

insert image description here
jdk installation path

  • Create a new classpath, then the variable value is

.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

Note that the preceding English period must not be omitted.

  • Add %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin after the path and click OK (system PATH, pay attention to put these two in front.)
    insert image description here

demo

We implement jdk switching by changing the number behind javahome.

jdk9 demo jshell

insert image description here
insert image description here

jdk8

insert image description here
insert image description here

Three consecutive critical hits to knock out equipment, buns.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324136387&siteId=291194637