Home > Java > javaTutorial > Detailed explanation of java9 installation and jshell usage

Detailed explanation of java9 installation and jshell usage

黄舟
Release: 2017-09-28 09:35:07
Original
2241 people have browsed it

2017年9月21日,千呼万唤始出来,Java9终于发布了。作为自己天天接触的“对象”,还是应该多花点心思去了解她。后续再进一步了解详细特性。下面这篇文章主要给大家介绍了关于java9学习系列之安装与jshell使用的相关资料,需要的朋友可以参考下。

前言

随着标准Java的版本更新,开发者总是可以从升级后的版本中获取想要的功能。

本文将给大家详细介绍下mac下面的java9版本安装使用,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。

下载

官网地址http://www.oracle.com/technet...

脚本之家下载:http://www.jb51.net/softs/578567.html

安装路径

下载袭来是个pkg文件,双击安装,默认装到了/Library/Java这里,java9的Home地址是


/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Copy after login

看下版本


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)
Copy after login

jshell


 bin ./jshell
| 欢迎使用 JShell -- 版本 9
| 要大致了解该版本, 请键入: /help intro

jshell>
Copy after login

有了jshell就可以快速做一些验证,比如


jshell> "1,2,3,,4".split(",")
$2 ==> String[5] { "1", "2", "3", "", "4" }

jshell> " a b ".trim()
$3 ==> "a b"
Copy after login

imports

查看导入的类库


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.*
Copy after login

方法定义及调用


jshell> String hello(){return "htllo";}
| 已创建 方法 hello()

jshell> String hello(){return "hello";}
| 已修改 方法 hello()

jshell>

jshell>

jshell> /methods
| String hello()

jshell> hello()
$7 ==> "hello"
Copy after login

查看历史


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
Copy after login

总结

doc

Java 9 (Part 2): JShell Step by Step

The above is the detailed content of Detailed explanation of java9 installation and jshell usage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template