java9系列(二)docker运行java9

本文介绍下如何在docker运行java9

镜像

docker pull openjdk:9-jdk

启动

docker run -it openjdk:9-jdk /bin/jshell

然后就可以正常使用jshell了,比如

Sep 22, 2017 2:16:12 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
|  Welcome to JShell -- Version 9-Debian
|  For an introduction type: /help intro

jshell> Arrays.asList(1,2,3,4).stream().limit(3).forEach(e -> System.out.print(e))
123

退出

jshell> /exit
|  Goodbye

查看此镜像的java版本

docker run -it openjdk:9-jdk /bin/bash
root@44d1d18351a8:/# java -version
openjdk version "9-Debian"
OpenJDK Runtime Environment (build 9-Debian+0-9b181-4)
OpenJDK 64-Bit Server VM (build 9-Debian+0-9b181-4, mixed mode)

doc

相关推荐