Tag: java 9

为什么Java 9不会简单地将类路径上的所有JAR转换为自动模块?

为了理解我们的类别: 平台显式模块 应用显式模块 打开模块 自动模块 未命名的模块 类路径中的所有类和jar都将是未命名模块的一部分。 但为什么我们需要呢? 自动模块的优势在哪里? 我可以“要求”那些该死的传统jar子,使它们成为一个自动模块。 我没有把它包括在内吗?

如何在JShell中运行作为片段添加的整个Java文件?

我尝试安装JDK 9 Early access version 172来玩JShell。 当我尝试打开一个简单的java文件并在将其添加为片段后执行它时,它只显示了修改后的类Test并增加了片段编号。 你能帮我理解我哪里出错了吗? | Welcome to JShell — Version 9-ea | For an introduction type: /help intro jshell> /open G:\kavitha\Test.java jshell> /list 1 : public class Test{ public static void main(String[] args){ int i = 1; int j = 2; System.out.println(“Sum of 1 and 2 is : ” + (i+j)); […]

使用Log4j2 2.10.0运行Java 9模块

我正在尝试运行我创建的Java 9模块,它使用Log4j2 2.10.0。 我遇到的问题是我得到了一个 java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil 在做LogManager.getLogger() 。 它找到了LogManager类,但是当它从StatusLogger内部调用new PropertiesUtil(“log4j2.StatusLogger.properties”) ,它会得到上述错误。 如何修复/找到解决方法? 添加信息: 堆栈跟踪: Exception in thread “main” java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil at org.apache.logging.log4j/org.apache.logging.log4j.status.StatusLogger.(StatusLogger.java:71) at org.apache.logging.log4j/org.apache.logging.log4j.LogManager.(LogManager.java:60) at com.EvolutionarySoftwareSystems.Utilities/com.EvolutionarySoftwareSystems.Utilities.Base.DebugAble.(DebugAble.java:45) 更奇怪的是我可以直接调用invoke:来自我的代码的new PropertiesUtil(“string”) ,它找到了类。 我正在使用日食氧气4.7.1a。 我的eclipse启动配置文件: 模块文件: module com.EvolutionarySoftwareSystems.Evolver { // // // Export the com.EvolutionarySoftwareSystems package // requires com.EvolutionarySoftwareSystems.Base; requires com.EvolutionarySoftwareSystems.Utilities; […]

Apache POI发生了非法reflection访问操作

我正在使用Apache POI来处理excel文件,从Java 9开始我收到此消息,根据这篇文章JDK9:发生了非法的reflection访问操作。 org.python.core.PySystemState我们应该等待开发人员解决问题,但是我应该在新的生产版本中保留它吗? 如果我跳过警告,我认为这应该不是问题。 WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.poi.util.DocumentHelper (file:/T:/Workspace/Java/Sections%20Manager/libs/poi/poi-ooxml-3.17.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int) WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.DocumentHelper WARNING: Use –illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a […]

“检测到必需的基于文件名的自动模块。”警告意味着什么?

在我的多模块项目中,我只为少数模块创建了module-info.java 。 在使用maven-compiler-plugin:3.7.0我收到了下一个警告: [警告] *检测到必需的基于文件名的自动模块。 请不要将此项目发布到公共工件库! * 这是什么意思? 那是因为我只有几个模块与module-info.java而不是整个项目?

使用Gradle构建Kotlin + Java 9项目

我对Gradle(和Java 9,说实话)相当新,我正在尝试使用Gradle构建一个简单的库项目,它是Java 9和Kotlin的混合体。 更详细地说,Java中有一个接口,Kotlin中有一个实现; 我会在Kotlin做一切,但是modules-info.java无论如何都是java,所以我决定这样做。 我正在构建IntelliJ Idea,外部定义了1.2.0 kotlin插件和gradle 4.3.1。 文件系统架构是: + src + main + java + some.package – Roundabout.java [an interface] – module-info.java + kotlin + some.package.impl – RoundaboutImpl.kt [implementing the interface] module-info.java是: module some.package { requires kotlin.stdlib; exports some.package; } 和build.gradle是: buildscript { ext.kotlin_version = ‘1.2.0’ repositories { mavenCentral() } dependencies { classpath […]

我需要为JDK 1.9下载什么泽西版?

我使用的是jdk 1.9。 我想提出一个简单的ReST服务。 使用maven原型创建项目: jersey-quickstart-webapp 。 然后我继续修改了pom.xml和web.xml。 我的maven配置如下所示: 4.0.0 restWebService restWebService war 1.0-SNAPSHOT restWebService restWebService org.apache.maven.plugins maven-compiler-plugin 3.7.0 true 9 9 org.glassfish.jersey jersey-bom ${jersey.version} pom import org.springframework spring-core 5.0.0.RELEASE com.sun.jersey jersey-client 1.19.4 com.sun.jersey jersey-bundle 1.19.4 com.sun.jersey jersey-server 1.19.4 com.sun.jersey jersey-core 1.19.4 org.ow2.asm asm 6.0_BETA org.json json 20170516 com.sun.xml.bind jaxb-impl 2.3.0 javax.xml jaxb-api 2.1 javax.activation activation […]

使用Java 9将自定义JMOD添加到模块路径

我用这样的jmod工具创建了一个简单的JMOD文件 $JAVA_HOME/bin/jmod create –class-path classes test/samples.jmod 接下来,我尝试通过运行以下命令在该模块中执行一个类: java -mp test -m de.mypackage/de.mypackage.Test 这导致以下exception: Error occurred during initialization of VM java.lang.module.ResolutionException: JMOD files not supported: test/samples.jmod at java.lang.module.Resolver.findWithBeforeFinder(java.base@9-ea/Resolver.java:729) at java.lang.module.Resolver.resolveRequires(java.base@9-ea/Resolver.java:86) at java.lang.module.Configuration.resolveRequiresAndUses(java.base@9-ea/Configuration.java:370) at java.lang.module.ModuleDescriptor$1.resolveRequiresAndUses(java.base@9-ea/ModuleDescriptor.java:1986) at jdk.internal.module.ModuleBootstrap.boot(java.base@9-ea/ModuleBootstrap.java:263) at java.lang.System.initPhase2(java.base@9-ea/System.java:1928) 如果我只是将我的classes目录(我用来创建JMOD文件)设置为modulepath,那么一切都按预期工作。 通常不可能在JMOD上有JMOD文件吗? 如果是这种情况,有什么理由吗?

Scala与Java 9不兼容 – java.lang.NoClassDefFoundError

在我的电脑上安装Java 9后运行一个示例Scala SBT项目,我就接受了这个例外。 我已经尝试了一些我发现的解决方案,但没有。 Java 9和Scala之间是否存在任何不兼容性? Scala版本:2.12.3 Java版本:java版本“9” IDE:IntelliJ 提前致谢。 info] Compiling 7 Scala sources and 1 Java source to /Users/ermis/Projects/begining-scala/target/scala-2.12/classes… [info] pahEnabledFilters – Enabled Filters (see ): play.filters.csrf.CSRFFilter play.filters.headers.SecurityHeadersFilter play.filters.hosts.AllowedHostsFilter [info] play.api.Play – Application started (Dev) Uncaught error from thread [play-dev-mode-akka.actor.default- dispatcher-2]: javax/xml/bind/DatatypeConverter, shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for for ActorSystem[play-dev-mode] java.lang.NoClassDefFoundError: […]

Java 9集合工厂的用法

在List.of()或Collections.emptyList()和List.of(…)或Collections.unmodifiableList()中给出的注释和答案的上下文中,我提出了以下两条经验法则(也适用于Set和Map工厂)。 不要替换所有出现的事件 继续使用Collections.emptyList()以提高可读性,例如初始化惰性字段成员时: class Bean { private List beans = Collection.emptyList(); public List getBeans() { if (beans == Collections.EMPTY_LIST) { beans = new ArrayList(); } return beans; } } 使用新工厂作为方法参数构建器 当使用List参数调用可执行文件时,使用新工厂List.of()和变体作为快速和较少类型的版本。 以下是我目前的替代模式: Collections.emptyList() –> List.of() Collections.singletonList(a) –> List.of(a) Arrays.asList(a, …, z) –> List.of(a, …, z) 在Collections.indexOfSubList的虚构用法中,以下行 Collections.indexOfSubList(Arrays.asList(1, 2, 3), Collections.emptyList()); Collections.indexOfSubList(Arrays.asList(1, 2, 3), Collections.singletonList(1)); Collections.indexOfSubList(Arrays.asList(1, […]