我想从命令行检查本地安装的 jvm 的 java 模块的资源文件的内容。
基于有关jvm 中 mime 类型支持的问题,我想查看本地安装的 jvm/sun/net/www/content-types.properties模块中的内容。java.base
然而,当滚动浏览为 jvm 安装的文件时,我无法找到名为java.base.*. 但是我看到一个文件./lib/modules大小超过 130 MB。我怀疑该文件包含 module 的内容java.base。但 7-zip 无法将此文件作为存档打开。
如何使用命令行查看本地安装的 jvm/sun/net/www/content-types.properties模块中的内容?java.base
JDK9将(可能)引入一个模块系统.作为其中的一部分,Java类库将被模块化.
当找不到类时,这会导致异常,因为它们位于未指定为依赖项的模块中.
将使用模块系统创建哪些模块以及它们各自的内容是什么?
或者说不同:给定一个没有加载的类,我如何找到适当的模块作为依赖项?
例如,我有somefile-0.1.jarjar文件,其中包含JPMS模块.此外,我参考Module somemodule了这个模块.
如何通过Module获取jar文件名(使用somemodule参考)?我已经检查过Module API但没有找到办法.
所以我尝试将我的项目迁移到Java 9,但这个过程似乎并不像我想象的那么容易.我不断得到一些关于隐形包的错误,我可以用我的pom中的以下参数修复:
<compilerArgs>
<arg>--add-modules</arg>
<arg>java.se.ee</arg>
</compilerArgs>
Run Code Online (Sandbox Code Playgroud)
但我仍然得到以下错误:
cannot find symbol
[ERROR] symbol: class Priority
[ERROR] location: package javax.annotation
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激
我使用gradle和jigsaw插件构建了一个小型(hello world style)java 9项目.
对于junit测试,我尝试访问某个文件作为资源,但classLoader.getResource(filename)无法找到该文件.
通常你把文件作为src/test/resources/foo.txt并将其作为访问它/foo.txt,但是对于Java 9,它看起来像是变化了,资源(类似于类)封装在模块中.
我在哪里准备好将gradle资源文件正确打包?
之后在测试中访问该文件的正确方法是什么?
我忘记阅读的文件是什么?:)
更确切地说,我建立了一个小型测试项目.更改到该目录后使用git clone https://github.com/michas2/java_9_resource_test.git并执行gradle build.(我正在使用gradle 4.6,但这应该不是问题.)
结构如下所示:
.
??? build.gradle
??? src
??? main
? ??? java
? ??? module-info.java
? ??? resourceTest
? ??? Main.java
??? test
??? java
? ??? resourceTest
? ??? MainTest.java
??? resources
??? resourceTest
??? test.txt
Run Code Online (Sandbox Code Playgroud)
我试图访问资源使用this.getClass().getResource("/resourceTest/test.txt"),不幸的是,null作为回报.
我正在升级我们的应用程序以使用 Java 9(婴儿学步......一旦我们让 9 工作,我们将跳到 10)。我们遇到的问题之一是在运行时,我们收到模块异常,而我似乎无法弄清楚发生了什么。诚然,我对模块很陌生,并且已经阅读了我能找到的有关该主题的所有内容,但我猜这可能是一个简单的答案。
调用的运行时间是
java --add-modules java.se,java.se.ee -cp mainjar.jar:jaxb-api.jar:jaxb-impl.jar:jaxb-core.jar foo.bar.Launch
Run Code Online (Sandbox Code Playgroud)
尝试读取 XML 数据时发生异常:
WARN:09:22:10.777 [main] (Preference:969) - Failed to unmarshal preference value for key [launch.maxMemory]: javax.xml.bind.JAXBException: Package java.lang with JAXB class java.lang.Integer defined in a module java.base must be open to at least java.xml.bind module.
javax.xml.bind.JAXBException: Package java.lang with JAXB class java.lang.Integer defined in a module java.base must be open to at least java.xml.bind module.
at java.xml.bind@9.0.4/javax.xml.bind.ModuleUtil.delegateAddOpensToImplModule(Unknown Source)
at java.xml.bind@9.0.4/javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at java.xml.bind@9.0.4/javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at java.xml.bind@9.0.4/javax.xml.bind.ContextFinder.find(Unknown Source) …Run Code Online (Sandbox Code Playgroud) 我习惯从以下链接访问Java SE文档,我可以从中搜索java.awt,java.util等软件包:
https://docs.oracle.com/javase/7/docs/api/
https://docs.oracle.com/javase/8/docs/api/
但是,当访问版本9的类似链接时,我可以看到一些模块结构与Java SE文档非常不同,直到版本8."旧"Java包发生了什么?
我的硒测试有一个奇怪的问题
当我打开我的 chrome 浏览器时,我收到 2 个错误:
[1569419754.430][WARNING]: Timed out connecting to Chrome, retrying...
[1569419759.899][WARNING]: Timed out connecting to Chrome, retrying...
Run Code Online (Sandbox Code Playgroud)
在浏览器实际打开之前。我还注意到在测试结束时有很多警告:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openqa.selenium.os.ProcessUtils
WARNING: Please consider reporting this to the maintainers of org.openqa.selenium.os.ProcessUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Run Code Online (Sandbox Code Playgroud)
我尝试更新 maven 依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但是它破坏了我所有的测试,我无法初始化浏览器,还有其他人有这个问题吗?
给定两个模块m1并m2在模块路径上:
java -version
openjdk version "11.0.2" 2019-01-15
java -p M2/bin:M1/bin --list-modules
...
m1 <path>M1/bin/
m2 <path>M2/bin/
Run Code Online (Sandbox Code Playgroud)
运行 modulem2并指定--add-readsfromm2到时m1:
java -p M2/bin:M1/bin --add-reads m2=m1 -m m2/p2.C2
WARNING: Unknown module: m1 specified to --add-reads
...
Run Code Online (Sandbox Code Playgroud)
Java 无法看到该模块m1,即使在使用时--list-modules它是清晰可见的。
如何识别--add-reads模块?
在将大型 JEE8 应用程序移植到 Java 17 时,我IllegalAccessException在渲染一个简单的 EL 表达式时偶然发现了一个:#{myWarBean.defaultTZ.rawOffset}。我设法在github 上的 SSCCE中重现了该问题。当您在 Wildfly 应用程序服务器(我使用的是 26.1.1.Final)上运行应用程序时,您会得到以下堆栈跟踪:
SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-1) Error Rendering View[/index.xhtml]: javax.el.ELException: /index.xhtml @23,74 value="raw offset=#{myWarBean.defaultTZ.rawOffset}": java.lang.IllegalAccessException: class javax.el.BeanELResolver cannot access class sun.util.calendar.ZoneInfo (in module java.base) because module java.base does not export sun.util.calendar to unnamed module @6a1cb0de
at com.sun.jsf-impl@2.3.17.SP01//com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:77)
at javax.faces.api@3.1.0.SP01//javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.api@3.1.0.SP01//javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181)
at javax.faces.api@3.1.0.SP01//javax.faces.component.UIOutput.getValue(UIOutput.java:140)
at com.sun.jsf-impl@2.3.17.SP01//com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:198)
at com.sun.jsf-impl@2.3.17.SP01//com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:328)
at com.sun.jsf-impl@2.3.17.SP01//com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:143)
at javax.faces.api@3.1.0.SP01//javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:600)
at com.sun.jsf-impl@2.3.17.SP01//com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:286)
at com.sun.jsf-impl@2.3.17.SP01//com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:90)
at javax.faces.api@3.1.0.SP01//javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:571)
at javax.faces.api@3.1.0.SP01//javax.faces.component.UIComponent.encodeAll(UIComponent.java:1648)
at javax.faces.api@3.1.0.SP01//javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at javax.faces.api@3.1.0.SP01//javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651) …Run Code Online (Sandbox Code Playgroud) java-module ×10
java ×9
java-9 ×6
command-line ×1
el ×1
gradle ×1
java-17 ×1
java-platform-module-system ×1
javadoc ×1
jaxb ×1
jsf ×1
jvm ×1
maven ×1
selenium ×1