Slide 20
Slide 20 text
WHAT’S NEW IN JAVA >10: DECOUPLING MODULES USING SERVICES
DEFINE THE HELLOWORLD CLI MODULE: HELLO.JAVA
package com.billyjf.helloworld;
import com.billyjf.hello.api.HelloProvider;
import java.util.ServiceLoader;
public class Hello {
public static void main(String... args) {
Iterable providers =
ServiceLoader.load(HelloProvider.class);
System.out.println(String.format("Hello Modular %s!",
providers.iterator().next().getMessage()));
}
}
CHECK OUT HTTPS://GITHUB.COM/BILLYJF/JAVA9-HELLO-MODULES