――I didn't care, but java9 was included in eclipse. ――I'm not sure about the new function itself, but I tried it because jshell became available.
--Enter with the jshell
command and exit with
/ exit```.
sh-3.2$ pwd
/Applications/Eclipse_4.7.2.app/Contents/java/9/Home/bin
sh-3.2$ ./jshell
|Welcome to JShell--Version 9.0.1
|For an overview, type:: /help intro
jshell> System.out.println("HELLO WORLD!")
HELLO WORLD!
jshell> List<String> list = new ArrayList<>()
list ==> []
jshell> list.add("HELLO")
$3 ==> true
jshell> list.add("WORLD")
$4 ==> true
jshell> list
list ==> [HELLO, WORLD]
jshell> String.join("-",list)
$6 ==> "HELLO-WORLD"
jshell> /exit
|Finish
――You don't need import java.util.List
. Is ```import java.util. * `` `Implicit declaration?
――Isn't it nice to be able to easily see the contents of variables?
sh-3.2$ ./jshell
|Welcome to JShell--Version 9.0.1
|For an overview, type:: /help intro
jshell> ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
|error:
|Can't find symbol
|symbol:Variable ManagementFactory
|place:class
| ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
| ^---------------^
jshell> import java.lang.management.ManagementFactory
jshell> ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
$2 ==> "4449"
――On the other hand, in ps, it is as below.
sh-3.2$ ps
PID TTY TIME CMD
4448 ttys000 0:08.22 ./jshell
4449 ttys000 0:00.60 /Applications/Eclipse_4.7.2.app/Contents/java/9/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=localhost:64584 jdk.jshell.execution.R
Recommended Posts