WYJUG Meetup 21/08/2019

Today was the first meetup of the WYJUG. The focus of the session was “Hacking on Java 13”.

There were 3 aims to the session:

Download And Install Java 13

Java 13 can be downloaded from: https://jdk.java.net/13/

Afrer downlading, simply unzip and copy the contents of the zip to /Libraries/Java/JavaVirtualMachines.

To ensure all versions of Java can run independently on Mac, add the following to your .bash_profile file.

export JAVA_13_HOME=$(/usr/libexec/java_home -v13)
alias java13='export JAVA_HOME=$JAVA_13_HOME’

You can them execute the java13 command from the terminal to switch the default Java to version 13.

 ~/Downloads $ java13
 ~/Downloads $ java -version
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)
 ~/Downloads $ javac -version
 javac 13

Try Out Existing Software On Java 13

The following sofware was tried:

Try Out Some Of The New Features In Java 13

Due to time constraints, the only feature we looked at was TextBlocks. For this we wrote a Simple Hello World Program:

package com.test.java13;

public class Hello {
    public static void main(String[] args) {

        String hello =  """
        Hello
        from
        Java
        13
        """;

        System.out.println(hello);
    }
}

To enable the maven project to compile with Java 13, using TextBlocks, we had to use the Maven Compiler Plugin and configure the release and compiler args as below:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <release>13</release>
        <compilerArgs>
            --enable-preview
        </compilerArgs>
    </configuration>
</plugin>

The application could be executed from the command line via:

 ~/Code/wyjug/java13 $ java --enable-preview -cp target/java13-1.0-SNAPSHOT.jar com.test.java13.Hello

Follow Us

You can follow us on Twitter @wyjug, on Facebook at wyjug, or can get in touch via email at wyjug @ outlook.com

Looking forward to hearing and speaking to you all :)