[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:
parent
61504c948b
commit
ee036aacca
0
core-java-9/compile-modules.sh
Normal file → Executable file
0
core-java-9/compile-modules.sh
Normal file → Executable file
2
core-java-9/compile-simple-modules.sh
Executable file
2
core-java-9/compile-simple-modules.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
javac -d outDir --module-source-path src/simple-modules $(find src/simple-modules -name "*.java")
|
2
core-java-9/run-simple-module-app.sh
Executable file
2
core-java-9/run-simple-module-app.sh
Executable 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
0
core-java-9/run-student-client.sh
Normal file → Executable file
@ -0,0 +1,5 @@
|
||||
package com.baeldung.modules.hello;
|
||||
|
||||
public interface HelloInterface {
|
||||
public void sayHello();
|
||||
}
|
@ -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!");
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
module hello.modules {
|
||||
exports com.baeldung.modules.hello;
|
||||
provides com.baeldung.modules.hello.HelloInterface with com.baeldung.modules.hello.HelloModules;
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
4
core-java-9/src/simple-modules/main.app/module-info.java
Normal file
4
core-java-9/src/simple-modules/main.app/module-info.java
Normal file
@ -0,0 +1,4 @@
|
||||
module main.app {
|
||||
requires hello.modules;
|
||||
uses com.baeldung.modules.hello.HelloInterface;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user