java-module

Running Java 9 module using Log4j2 2.10.0

徘徊边缘 提交于 2019-12-04 09:51:26
问题 I am trying to run a Java 9 module I've created which uses Log4j2 2.10.0. The problem I'm running into is that I get a java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil when doing a LogManager.getLogger() . It finds the LogManager class fine, but when it get to the new PropertiesUtil("log4j2.StatusLogger.properties") call from inside StatusLogger , it gets the above error. How do fix/find a workaround for this? Added Info: Stack Trace:

Java 9 sub-packages split across modules

半腔热情 提交于 2019-12-04 02:22:11
问题 In Java 9, can I split sub-packages across modules? For example, can I have com.example.foo in one module and com.example.foo.bar in another module? This seems like a simple question, but for some reason I'm not able to find a direct answer after some searching. An authoritative reference would be appreciated. I assume I can have sibling sub-packages in different modules, e.g. com.example.foo and com.example.other . 回答1: There's no such thing as a "sub-package". my.package and my.package.sub

Module javafx.controls not found in Java 9

坚强是说给别人听的谎言 提交于 2019-12-04 01:20:59
问题 I have two JPMS module in two files: modulea.jar and moduleb.jar . Modulea requires javafx.controls module. I need to use these modules in new layer, so I do: ModuleFinder finder = ModuleFinder.of(modAPath, modBPath); ModuleLayer parent = ModuleLayer.boot(); Configuration cf = parent.configuration().resolveAndBind(finder, ModuleFinder.of(), new HashSet<>()); ClassLoader scl = ClassLoader.getSystemClassLoader(); ModuleLayer newLayer = parent.defineModulesWithOneLoader(cf, scl); I thought that

java 9: JLink created invalid images - missing module executable script

醉酒当歌 提交于 2019-12-03 14:43:51
I am creating a sample application with 3 modules user , dept and account . In my user module, I have a main class and compile my modules with the following command: javac -d target --module-source-path src $(find -name "*.java") After compiling, execute following command for run: java -p target -m com.user/com.user.info.Launcher The output after running java modules are successful. But when trying to create runtime image using jlink the image created successfully but module executable script is not there. For create an image, I am using the following command: jlink --module-path $JAVA_HOME

Limit modules added by javapackager

泄露秘密 提交于 2019-12-03 13:01:50
I am trying to reduce the size of my application by limiting the modules that it includes. I already did this for my runtime using jlink . However, when I run javapackager using the --add-modules and --limit-modules options with a comma-separated list of the same small set of modules I used for the runtime, it insists on adding all of the modules anyway. It doesn't seem to want to honor the option I'm giving it. How can I get the tool to limit the modules it adds to my app bundle? "Adding modules: [java.base, java.desktop, java.naming, java.sql, java.xml, java.logging, java.management, java

Java 9 overlapping non-exported packages

末鹿安然 提交于 2019-12-03 07:07:21
Various resources ( infoq , jigsaw-dev , osdir ) indicate that having the same package in different java modules will lead to a LayerInstantiationException , even when the packages are internal to the module (non-exported). This seems to be the exact opposite of what the requirements say : The Java compiler, virtual machine, and run-time system must ensure that modules that contain packages of the same name do not interfere with each other. If two distinct modules contain packages of the same name then, from the perspective of each module, all of the types and members in that package are

How to make Multi-Release JAR Files with Gradle?

。_饼干妹妹 提交于 2019-12-03 05:16:30
Java9 introduces with Multi-Release JARs . Let's say that I have multimodule Gradle project using java8: project-root settings.gradle build.gradle /module1 /src ... (common maven structure) /module2 /module3 This is a common multi-module project in Gradle. Let's say I need MR-Jar for module1 . I can't add module1-java9 targeting Java9 because the base is on 8 - so far, both my Gradle and IntelliJ IDEA complains. Gradle is compiled with the java8, but I need to enable java9 runtime just for the module (don't know how); in IntelliJ IDEA I can set the java9 runtime for the module, but it gets

cannot compile Java 9 module with --patch-module in IntelliJ IDEA 2017.2.1

拥有回忆 提交于 2019-12-03 04:41:40
I am trying to acquaint myself with Java 9 modules and how to define them in IntelliJ. Among other things, I want to solve a split package problem using the --patch-module compiler/JVM flag and I don't know how to make it work in IntelliJ. I am using IntelliJ IDEA 2017.2.1 Build #IC 172.3544.35 with Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode). This is my source file MyImmutableList.java : package com.google.common.collect; public class MyImmutableList extends RegularImmutableList { public MyImmutableList(Object[] array) { super(array); } } It belongs to my module com.effjava

Running Java 9 module using Log4j2 2.10.0

[亡魂溺海] 提交于 2019-12-03 03:33:48
I am trying to run a Java 9 module I've created which uses Log4j2 2.10.0. The problem I'm running into is that I get a java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil when doing a LogManager.getLogger() . It finds the LogManager class fine, but when it get to the new PropertiesUtil("log4j2.StatusLogger.properties") call from inside StatusLogger , it gets the above error. How do fix/find a workaround for this? Added Info: Stack Trace: Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging

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