Java 10 install on Ubuntu and what's new
OpenJDK 10 was released on 20 March 2018 with new features like:
- Local-Variable Type Inference - extending type inference of local variables declarations with initializers.
- Experimental JIT Compiler - integration of the Graal dynamic compiler for the Linux x64 platform
- Parallel full garbage collection for the G1 garbage collector
- Docker improvements. If running on Linux systems, the JVM will know if it is running in a Docker container.
- Shorter startup times for the jShell
- Improved Garbage-Collector Interface
- Consolidate the JDK Forest into a Single Repository
You can see the list of all features here: JDK 10 new features
Install java 10 on Ubuntu
You can check how to install java 9 via apt-get: How to install OpenJDK 9 on Ubuntu 16
Since java is not available in apt repository we will donwloaded and then install it. First you need to download the version that you want to use:
select folder for installation:
cd temp
Since I want just to play with this version I'll intall it in folder temp.
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10+46/76eac37278c24557a3c4199677f19b62/jdk-10_linux-x64_bin.tar.gz
you can see them here: Java SE Development Kit 10 Downloads
then you need to install it by:
tar -xzvf jdk-10_linux-x64_bin.tar.gz
after the installation:
./java -version
because my default java is 9. I need to go the folder of the newly installed jdk and run the java command from there with ./
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
Test java 10
how to use jshell and commands: Java 9 play with jshell ( interactive java console) Ubuntu
In order to test the newly installed java we will use jshell:
cd jdk-10/bin/
./jshell
and you will see this:
| Welcome to JShell -- Version 10
| For an introduction type: /help intro
test new feature: Local-Variable Type Inference
java 10:
jshell> var x = 5
x ==> 5
java 9:
-> var x = 5;
| Error:
| cannot find symbol
| symbol: class var
| var x = 5;
| ^-^
java 10:
var list = new ArrayList<String>(); // infers ArrayList<String>
var stream = list.stream(); // infers Stream<String>
Java 10 info
- Documentation: JDK 10 General-Availability Release
- JDK 10 Release Notes or what's new: JDK 10 Release Notes
- How to install java on Linux 64 - Linux 64-bit installation instructions for Java
- Java version history
I will not install java 10 in production because of the small number of changes and the recent realese for java 11 which will be LTS. Still you can install and test this version. Performance and garbage collector improvements are expected.