From Java SE Development Kit 10 --Downloads, the installer for the JDK for macOS jdk-10_osx-x64_bin Download .dmg.
Open jdk-10_osx-x64_bin.dmg. Double click to install.
Requires 700MB or more free space.
Confirm that the installation was successful.
$ java -version
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)
$ javac -version
javac 10
Sample code HelloWorld.java is prepared to use the type inference (JEP 286: Local \ -Variable Type Inference) that seems to have been introduced in Java 10. Declare the variable message, which is known to contain the String type, with var.
public class HelloWorld {
public static void main(String[] args) {
var message = args[0];
System.out.println(message);
}
}
compile.
$ javac HelloWorld.java
Run. It worked as expected.
$ java HelloWorld "hello, world"
hello, world
Recommended Posts