[BAEL-1615] Code to support article. (#3867)

* [BAEL-1615] Code to support article.

* Adding example of provides...with

* Adding uses to main module
This commit is contained in:
christopherfranklin 2018-04-11 14:27:31 -04:00 committed by Grzegorz Piwowarek
parent 61504c948b
commit ee036aacca
9 changed files with 40 additions and 0 deletions

0
core-java-9/compile-modules.sh Normal file → Executable file
View File

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
javac -d outDir --module-source-path src/simple-modules $(find src/simple-modules -name "*.java")

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
java --module-path outDir -m main.app/com.baeldung.modules.main.MainApp

0
core-java-9/run-student-client.sh Normal file → Executable file
View File

View File

@ -0,0 +1,5 @@
package com.baeldung.modules.hello;
public interface HelloInterface {
public void sayHello();
}

View File

@ -0,0 +1,11 @@
package com.baeldung.modules.hello;
public class HelloModules implements HelloInterface {
public static void doSomething() {
System.out.println("Hello, Modules!");
}
public void sayHello() {
System.out.println("Hello!");
}
}

View File

@ -0,0 +1,4 @@
module hello.modules {
exports com.baeldung.modules.hello;
provides com.baeldung.modules.hello.HelloInterface with com.baeldung.modules.hello.HelloModules;
}

View File

@ -0,0 +1,12 @@
package com.baeldung.modules.main;
import com.baeldung.modules.hello.HelloModules;
public class MainApp {
public static void main(String[] args) {
HelloModules.doSomething();
HelloModules module = new HelloModules();
module.sayHello();
}
}

View File

@ -0,0 +1,4 @@
module main.app {
requires hello.modules;
uses com.baeldung.modules.hello.HelloInterface;
}