Skip to content

Commit ee036aa

Browse files
christopherfranklinpivovarit
authored andcommitted
[BAEL-1615] Code to support article. (eugenp#3867)
* [BAEL-1615] Code to support article. * Adding example of provides...with * Adding uses to main module
1 parent 61504c9 commit ee036aa

9 files changed

Lines changed: 40 additions & 0 deletions

File tree

core-java-9/compile-modules.sh

100644100755
File mode changed.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
javac -d outDir --module-source-path src/simple-modules $(find src/simple-modules -name "*.java")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
java --module-path outDir -m main.app/com.baeldung.modules.main.MainApp

core-java-9/run-student-client.sh

100644100755
File mode changed.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.baeldung.modules.hello;
2+
3+
public interface HelloInterface {
4+
public void sayHello();
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.modules.hello;
2+
3+
public class HelloModules implements HelloInterface {
4+
public static void doSomething() {
5+
System.out.println("Hello, Modules!");
6+
}
7+
8+
public void sayHello() {
9+
System.out.println("Hello!");
10+
}
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module hello.modules {
2+
exports com.baeldung.modules.hello;
3+
provides com.baeldung.modules.hello.HelloInterface with com.baeldung.modules.hello.HelloModules;
4+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.modules.main;
2+
3+
import com.baeldung.modules.hello.HelloModules;
4+
5+
public class MainApp {
6+
public static void main(String[] args) {
7+
HelloModules.doSomething();
8+
9+
HelloModules module = new HelloModules();
10+
module.sayHello();
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module main.app {
2+
requires hello.modules;
3+
uses com.baeldung.modules.hello.HelloInterface;
4+
}

0 commit comments

Comments
 (0)