JDK12安裝教程及新特性淺談

一.安裝教程

下載地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html

step 1

 

step 2

step 3

在山區網絡不好......玩兩把單機 回來繼續安裝

step 4

下載好的jdk,雙擊即可安裝

建議更改安裝位置

 

step 5

繼續點擊下一步安裝,最後關閉即可

step 6

環境變量配置

右擊【此電腦】,點擊【屬性】,選擇【高級系統設置】

 

【高級】--> 【環境變量】

如果針對用戶,可以 用戶變量 配置,這裏在系統變量配置全局

點擊【新建】 配置 JAVA_HOME 確定即可

 

雙擊【Path】或單擊【編輯】配置 Path

點擊新增,輸入 %JAVA_HOME%\bin,確定

jdk9後不需要配置CLASSPATH變量

 

step 7 

驗證jdk安裝是否成功

打開【命令提示符】

方式1.

 

方式2. win+r

 

輸入  java -version ,若出現java版本信息則說明安裝成功,如下圖:

 

 

二.新特性

地址:http://openjdk.java.net/projects/

 

jdk12(GA 2019/03/19)

189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) Shenandoah:低暫停時間垃圾收集器(實驗性)
230: Microbenchmark Suite Microbenchmark套房
325: Switch Expressions (Preview) 切換表達式(預覽)
334: JVM Constants API JVM常量API
340: One AArch64 Port, Not Two 一個AArch64端口,而不是兩個
341: Default CDS Archives 默認CDS檔案
344: Abortable Mixed Collections for G1 G1的可流動混合收集
346: Promptly Return Unused Committed Memory from G1 從G1中立即返回未使用的已提交內存

a--切換表達式,省去 break

switch (day) {
case SATURDAY, SUNDAY -> log.info("去旅遊");
case TUESDAY -> log.info("上班");
case THURSDAY -> log.info("上課");
}


String whereTo = switch (day) {
case SATURDAY, SUNDAY -> "去旅遊";
case TUESDAY -> "上班";
case THURSDAY -> "上課";
};

 

jdk11(GA 2018/09/25)

181: Nest-Based Access Control 基於嵌套的訪問控制
309:  Dynamic Class-File Constants 動態類 - 文件常量
315:  Improve Aarch64 Intrinsics 改進Aarch64內在函數
318:  Epsilon: A No-Op Garbage Collector Epsilon:無操作垃圾收集器
320:  Remove the Java EE and CORBA Modules 移除Java EE和CORBA模塊
321:  HTTP Client (Standard) HTTP客戶端(標準)
323:  Local-Variable Syntax for Lambda Parameters 本地變量Lambda參數
324:  Key Agreement with Curve25519 and Curve448 與Curve25519和Curve448的密鑰協議
327:  Unicode 10 Unicode 10
328:  Flight Recorder

Flight Recorder(飛行記錄器),基於OS、JVM和JDK的事件

產生的數據收集框架

329:  ChaCha20 and Poly1305 Cryptographic Algorithms ChaCha20和Poly1305加密算法
330:  Launch Single-File Source-Code Programs 啓動單文件源代碼程序
331:  Low-Overhead Heap Profiling 低開銷堆分析
332:  Transport Layer Security (TLS) 1.3 傳輸層安全性(TLS)1.3
333:  ZGC: A Scalable Low-Latency Garbage Collector(Experimental) ZGC:可擴展的低延遲垃圾收集器(實驗性)
335:  Deprecate the Nashorn JavaScript Engine 棄用Nashorn JavaScript引擎
336:  Deprecate the Pack200 Tools and API 棄用Pack200工具和API

a--字符串加強

// 複製

"Java".repeat(3); // "JavaJavaJava"

//統計 行數

"A\nB\nC\nA\nB\nC".lines().count(); // 6

 

 

jdk10(GA 2018/03/20)

286:  Local-Variable Type Inference 局部變量類型推斷
296:  Consolidate the JDK Forest into a Single Repository 將JDK林合併到單個存儲庫
304:  Garbage-Collector Interface 垃圾收集器接口
307:  Parallel Full GC for G1 G1的並行全GC
310:  Application Class-Data Sharing 應用程序類 - 數據共享
312:  Thread-Local Handshakes 線程局部握手
313:  Remove the Native-Header Generation Tool (javah) 移除本機頭生成工具(javah)
314:  Additional Unicode Language-Tag Extensions 附加的Unicode語言 - 標記擴展
316:  Heap Allocation on Alternative Memory Devices 替代存儲器設備上的堆分配
317:  Experimental Java-Based JIT Compiler 基於Java的實驗JIT編譯器
319:  Root Certificates 根證書
322:  Time-Based Release Versioning 基於時間的發佈版本控制

 

    a--使用局部類型----var關鍵詞定義

var list = new LinkedList<String>();

 

jdk9

102:  Process API Updates 處理API更新
110:  HTTP 2 Client HTTP 2客戶端
143:  Improve Contended Locking 改進競爭鎖定
158:  Unified JVM Logging 統一JVM記錄
165:  Compiler Control 編譯器控制
193:  Variable Handles 可變句柄
197:  Segmented Code Cache 分段代碼高速緩存
199:  Smart Java Compilation, Phase Two 智能Java編譯,階段二
200:  The Modular JDK 模塊化JDK
201:  Modular Source Code 模塊化源代碼
211:  Elide Deprecation Warnings on Import Statements 導入語句的Elide 棄用警告
212:  Resolve Lint and Doclint Warnings 解決Lint和Doclint警告
213:  Milling Project Coin 銑削項目硬幣
214:  Remove GC Combinations Deprecated in JDK 8 刪除GC組合JDK 8中不推薦使用
215:  Tiered Attribution for javac javac的分層歸因
216:  Process Import Statements Correctly 正確處理導入語句
217:  Annotations Pipeline 2.0 註釋管道2.0
219:  Datagram Transport Layer Security (DTLS) 數據報傳輸層安全性(DTLS)
220:  Modular Run-Time Images 模塊化運行時圖像
221:  Simplified Doclet API 簡化的Doclet API
222:  jshell: The Java Shell (Read-Eval-Print Loop) jshell:Java Shell(讀取 - 評估 - 打印循環)
223:  New Version-String Scheme 新的Version-String Scheme
224:  HTML5 Javadoc HTML5 Javadoc
225:  Javadoc Search Javadoc Search
226:  UTF-8 Property Files UTF-8屬性文件
227:  Unicode 7.0 Unicode 7.0
228:  Add More Diagnostic Commands 添加更多診斷命令
229:  Create PKCS12 Keystores by Default 默認創建PKCS12密鑰庫
231:  Remove Launch-Time JRE Version Selection 刪除啓動時JRE版本選擇
232:  Improve Secure Application Performance 提高安全應用程序性能
233:  Generate Run-Time Compiler Tests Automatically 自動生成運行時編譯器測試
235:  Test Class-File Attributes Generated by javac 測試類文件屬性由javac生成
236:  Parser API for Nashorn Nashorn的解析器API
237:  Linux/AArch64 Port Linux / AArch64端口
238:  Multi-Release JAR Files 多版本JAR文件
240:  Remove the JVM TI hprof Agent 刪除JVM TI hprof代理
241:  Remove the jhat Tool 刪除jhat工具
243:  Java-Level JVM Compiler Interface Java級JVM編譯器接口
244:  TLS Application-Layer Protocol Negotiation Extension TLS應用層協議協商擴展
245:  Validate JVM Command-Line Flag Arguments 驗證JVM命令行標誌參數
246:  Leverage CPU Instructions for GHASH and RSA 利用GHASH和RSA的CPU指令
247:  Compile for Older Platform Versions 編譯較舊的平臺版本
248:  Make G1 the Default Garbage Collector 使G1成爲默認垃圾收集器
249:  OCSP Stapling for TLS 針對TLS的OCSP裝訂
250:  Store Interned Strings in CDS Archives 在CDS存檔中存儲間隔字符串
251:  Multi-Resolution Images 多分辨率圖像
252:  Use CLDR Locale Data by Default 默認使用CLDR區域設置數據
253:  Prepare JavaFX UI Controls & CSS APIs for Modularization 爲模塊化準備JavaFX UI控件和CSS API
254:  Compact Strings 緊湊字符串
255:  Merge Selected Xerces 2.11.0 Updates into JAXP 將選定的Xerces 2.11.0更新合併到JAXP
256:  BeanInfo Annotations BeanInfo註釋
257:  Update JavaFX/Media to Newer Version of GStreamer 將JavaFX / Media更新到更新版本的GStreamer
258:  HarfBuzz Font-Layout Engine HarfBuzzFonts-Layout Engine
259:  Stack-Walking API Stack-Walking API
260:  Encapsulate Most Internal APIs 封裝大多數內部API
261:  Module System 模塊系統
262:  TIFF Image I/O TIFF圖像I / O
263:  HiDPI Graphics on Windows and Linux Windows和Linux上的HiDPI圖形
264:  Platform Logging API and Service 平臺記錄API和服務
265:  Marlin Graphics Renderer Marlin圖形渲染器
266:  More Concurrency Updates 更多併發更新
267:  Unicode 8.0 Unicode 8.0
268:  XML Catalogs XML目錄
269:  Convenience Factory Methods for Collections 集合的便利工廠方法
270:  Reserved Stack Areas for Critical Sections 保留關鍵部分的堆棧區域
271:  Unified GC Logging 統一GC記錄
272:  Platform-Specific Desktop Features 特定於平臺的桌面功能
273:  DRBG-Based SecureRandom Implementations 基於DRBG的SecureRandom實現
274:  Enhanced Method Handles 增強的方法句柄
275:  Modular Java Application Packaging 模塊化Java應用程序打包
276:  Dynamic Linking of Language-Defined Object Models 語言定義的對象模型的動態鏈接
277:  Enhanced Deprecation 增強的棄使
278:  Additional Tests for Humongous Objects in G1 G1中的對象中的附加測試
279:  Improve Test-Failure Troubleshooting 改進測試失敗故障排除
280:  Indify String Concatenation 表示字符串連接
281:  HotSpot C++ Unit-Test Framework HotSpot C ++單元測試框架
282:  jlink: The Java Linker jlink:Java鏈接器
283:  Enable GTK 3 on Linux 在Linux上啓用GTK 3
284:  New HotSpot Build System 新的HotSpot構建系統
285:  Spin-Wait Hints 旋轉等待提示
287:  SHA-3 Hash Algorithms SHA-3哈希算法
288:  Disable SHA-1 Certificates 禁用SHA-1證書
289:  Deprecate the Applet API 棄用Applet API
290:  Filter Incoming Serialization Data 過濾傳入的序列化數據
291:  Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector 棄用併發標記掃描(CMS)垃圾收集器
292:  Implement Selected ECMAScript 6 Features in Nashorn 在Nashorn中實現選定的ECMAScript 6功能
294:  Linux/s390x Port Linux / s390x端口
295:  Ahead-of-Time Compilation 提前編譯
297:  Unified arm32/arm64 Port 統一arm32 / arm64端口
298:  Remove Demos and Samples 刪除演示和示例
299:  Reorganize Documentation 重新組織文檔

 

a--JShell:工具像腳本語言一樣來運行,在控制檯啓動 jshell ,獲取或校驗某些表達式的值,省去main方法測試。

如:

b--允許接口定義私有方法,私有方法可以作爲通用方法放在默認方法中調用。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章