module-info

What's the difference between requires and requires transitive statements in Java 9?

て烟熏妆下的殇ゞ 提交于 2019-12-17 17:38:28
问题 What's the difference between requires and requires transitive module statements in module declaration? For example: module foo { requires java.base; requires transitive java.compiler; } 回答1: Readability recap If module bar requires module drink , then the module system... enforces the presence of drink (called reliable configuration ) allows bar to read drink (called readability) allows code in bar to access public classes in exported packages in drink (called accessibility) Exactly the same

List the modules resolved during the application startup

你离开我真会死。 提交于 2019-12-17 04:07:12
问题 How can one get to know of the list of modules that have been resolved while the application has been started so as to figure out what all service providers are accessible from the root module. 回答1: Module Resolution The module resolution is a two-step process. The first step recursively enumerates the 'requires' directives of a set of root modules. If all the enumerated modules are observable, then the second step computes their readability graph. The readability graph embodies how modules

Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9

最后都变了- 提交于 2019-12-09 17:17:57
问题 I know that there are a lot question with similar error. I would appreciate before point as duplicate take in account that it only happens with Java 9. I do have java 9 installed C:\_pocs\ws_j9\java9-http-client>java -version java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode) C:\_pocs\ws_j9\java9-http-client>echo %JAVA_HOME% C:\Program Files\Java\jdk-9.0.1 To make simple the exemplification, if i download a very

Which module should I require in Java 9 to use JPA?

余生长醉 提交于 2019-12-09 11:31:11
问题 I'm testing Java 9 with a project which requires JPA ( javax.persistence.* classes). When I add the module-info.java and declare my module, all classes under javax.persistece package become unavailable. I searched a lot, but I couldn't find the module to require to use JPA in a Java 9 module project. UPDATE As Alan suggested, I ran $ jar --describe-module --file=javax.persistence-api-2.2.jar No module descriptor found. Derived automatic module. java.persistence@2.2 automatic requires java

Why is exporting the entire module not allowed?

你说的曾经没有我的故事 提交于 2019-12-09 02:27:06
问题 In Java 9's module declaration there are 2 constructs: exports com.foo; And opens com.foo; Where exports grants compile-time access, while opens allows runtime access, as reflection and resources. opens has one leniency over exports that you can define the whole module as open, resulting the same as explicitly opening every package: open module com.mod { But there's no similar construct exported module com.mod { My Question : Why is it so; what decisions has been made to allow opening the

Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9

末鹿安然 提交于 2019-12-04 04:59:30
I know that there are a lot question with similar error. I would appreciate before point as duplicate take in account that it only happens with Java 9. I do have java 9 installed C:\_pocs\ws_j9\java9-http-client>java -version java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode) C:\_pocs\ws_j9\java9-http-client>echo %JAVA_HOME% C:\Program Files\Java\jdk-9.0.1 To make simple the exemplification, if i download a very simple example https://examples.javacodegeeks.com/core-java/java-9-httpclient-example/ and I try/ mvn

Java 9: Possible to have 2 modules with same name on module path

孤街浪徒 提交于 2019-12-03 02:58:59
Is it possible to have 2 modules with the exact same name (but with slightly different contents) on the module path? As far as I can tell, the Java 9 compiler does not complain about it. I have 2 modules declared as follows: module com.dj.helper { exports com.dj.helper; } Both contain the com.dj.helper package but within the package the contents are different. Then in my main application, I am looking to import this module: module com.dj { requires com.dj.helper; } Both modules with the same name are on my module path. I was hoping that when compiling my com.dj module that the compiler would

log4j2 configuration file not found with java 9

拈花ヽ惹草 提交于 2019-12-01 06:43:10
I had a Java 8 project and my configuration file was in resource folder and everything worked fine. Now I switched to Java 9, added requirement for log4j.api , and configuration file cannot be found anymore. Do I need to add something else in my module-info file for the logger to find it's config? For now, it's like this module project.main { requires jdk.incubator.httpclient; requires jackson.databind; requires jackson.core; requires jackson.annotations; requires log4j.api; } The Project structure is as: The build.gradle file is as: The log4j~faq suggests using at least log4j-api-2.x and

Why is exporting the entire module not allowed?

人走茶凉 提交于 2019-12-01 03:06:55
In Java 9's module declaration there are 2 constructs: exports com.foo; And opens com.foo; Where exports grants compile-time access, while opens allows runtime access, as reflection and resources. opens has one leniency over exports that you can define the whole module as open, resulting the same as explicitly opening every package: open module com.mod { But there's no similar construct exported module com.mod { My Question : Why is it so; what decisions has been made to allow opening the whole module at once but not with exporting? A module's exports define its API, which should be

How to build java 9 dependencies from maven dependencies

落爺英雄遲暮 提交于 2019-11-30 16:23:30
问题 Java9 has introduced a strong modularity similar to OSGI and Maven Dependecies. Is there a maven plugin able to build the java 9 dependencies inspecting maven dependencies? For example, from <groupId>com.mycompany.app</groupId> <artifactId>my-module</artifactId> .... <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>23.3-jre</version> </dependency> to module my-module{ requires com.google.guava; exports com.mycompany.app; } I have read this article, but