Order
This article introduces the installation and use of java9 version 9 under mac.
download
Official website addresshttp://www.oracle.com/technet …
Installation path
Download hit is a pkg file, double-click the installation, the default installed to /Library/Java here, java9 Home address is
/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Look at the next version
bin ./java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
jshell
bin ./jshell
| 欢迎使用 JShell -- 版本 9
| 要大致了解该版本, 请键入: /help intro
jshell>
With jshell, you can quickly do some verification, such as
jshell> "1,2,3,,4".split(",")
$2 ==> String[5] { "1", "2", "3", "", "4" }
jshell> " a b ".trim()
$3 ==> "a b"
imports
View imported class libraries
jshell> /imports
| import java.io.*
| import java.math.*
| import java.net.*
| import java.nio.file.*
| import java.util.*
| import java.util.concurrent.*
| import java.util.function.*
| import java.util.prefs.*
| import java.util.regex.*
| import java.util.stream.*
Method Definition and Call
jshell> String hello(){return "htllo";}
| 已创建 方法 hello()
jshell> String hello(){return "hello";}
| 已修改 方法 hello()
jshell>
jshell>
jshell> /methods
| String hello()
jshell> hello()
$7 ==> "hello"
View history
jshell> /list
1 : int a = 1;
2 : "1,2,3,,4".split(",")
3 : " a b ".trim()
4 : new Date()
6 : String hello(){return "hello";}
7 : hello()
8 : 1/0