Sitemap

Member-only story

JAVA 18 Features

4 min readSep 5, 2022

--

This article is about the simple introduction of Java 18 and its new features.
The nine (9) JEPs in this final feature set are:

1. JEP 400: UTF-8 by Default

With different O.S. (linux , macOS or windows) and different locales (JP) we can face problems to converting Strings.
Here is an example of this hazard, where a Japanese text file encoded in UTF-8 on macOS is corrupted when read on Windows in US-English or Japanese locales:

java.io.FileReader(“hello.txt”) -> “こんにちは” (macOS)
java.io.FileReader(“hello.txt”) -> “ã?“ã‚“ã?«ã?¡ã? ” (Windows (en-US))
java.io.FileReader(“hello.txt”) -> “縺ォ縺。縺ッ” (Windows (ja-JP)

This JEP aims to make the default charset UTF-8. The Java standard character set determines how Strings are converted to bytes and vice versa in numerous methods of the JDK class library (e.g., when writing and reading a text file)

2. JEP 408: Simple Web Server

With the simple web server proposal, a command-line tool would be provided to start a minimal web server that serves static files only. No CGI or servlet-like functionality is available.
This JEP for simple test, educational vs..

It can be run like this:

$ jwebserver
If startup is successful then jwebserver prints a message to System.out listing the local address…

--

--