Created
January 25, 2019 19:48
-
-
Save beamerblvd/dd44652eca5fcca9722e3e630ee8aee2 to your computer and use it in GitHub Desktop.
Java 9 Modules split "sub-package" demonstration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.foo.implone; | |
import com.example.foo.SalutationProvider; | |
public final class StandardOutHelloer | |
{ | |
public static void main(String... arguments) | |
{ | |
System.out.println(new SalutationProvider().getSalutation()); | |
System.out.flush(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module com.example.foo.implone { | |
requires com.example.foo; | |
exports com.example.foo.implone; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.foo.impltwo; | |
import com.example.foo.SalutationProvider; | |
public final class StandardErrHelloer | |
{ | |
public static void main(String... arguments) | |
{ | |
System.err.println(new SalutationProvider().getSalutation()); | |
System.err.flush(); | |
System.exit(15); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module com.example.foo.impltwo { | |
requires com.example.foo; | |
exports com.example.foo.impltwo; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.foo; | |
public class SalutationProvider | |
{ | |
public SalutationProvider() | |
{ | |
} | |
public String getSalutation() | |
{ | |
return "Hello, World!"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module com.example.foo { | |
exports com.example.foo; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ java -Dfile.encoding=UTF-8 -p out/production/com-example-foo-impl1:out/production/com-example-foo -m com.example.foo.implone/com.example.foo.implone.StandardOutHelloer | |
Hello, World! | |
$ echo $? | |
0 | |
$ java -Dfile.encoding=UTF-8 -p out/production/com-example-foo-impl2:out/production/com-example-foo -m com.example.foo.impltwo/com.example.foo.impltwo.StandardErrHelloer | |
Hello, World! | |
$ echo $? | |
15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment