找不到编译.idl文件的idlj工具。检查/usr/bin并/usr/lib/jvm/java-11-jdk。它不是和JDK捆绑在一起的吗?如何添加idlj编译器?
PS 我更喜欢Python,并且不经常使用Java。如果这是一个愚蠢的问题,我很抱歉。
对于 jdk 8,我的步骤是计算进程运行时消耗了多少内存:
/usr/java/latest/bin>: ./jps
27116 Main
7591 Jps
2879 AmbusProcessor
Run Code Online (Sandbox Code Playgroud)
然后获取进程 ID 来检查堆的状态:
/usr/java/latest/bin>: ./jmap -heap 2879
Attaching to process ID 2879, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.45-b08
using thread-local object allocation.
Parallel GC with 13 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 68719476736 (65536.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Java 8 迁移到 Java 11,但收到此错误:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project Core: Fatal error compiling: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException: javax.xml.bind.JAXBException
Run Code Online (Sandbox Code Playgroud)
现在,我尝试将此依赖项添加到我的 pom.xml 文件中来解决此问题:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但我不断收到完全相同的问题。我也尝试过2.3.0版本。
我查看了有效的 POM,其中出现了 jaxb-api 依赖项。另外,我打开了 maven 下载的 jar 文件,只是为了验证该类是否存在。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.core</groupId>
<artifactId>Core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Core</name>
<properties>
<maven.version>3.8.0</maven.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
... <!-- Other Sonar settings -->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency> …Run Code Online (Sandbox Code Playgroud) PMD 失败:...规则:UnusedPrivateMethod 优先级:3 避免未使用的私有方法,例如“printMyString(String)”
private void anyMethod() {
var myString = "a String";
printMyString(myString);
}
private void printMyString(String string) {
System.out.println(string);
}
Run Code Online (Sandbox Code Playgroud)
使用maven这个插件
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.12.0</version>
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Spring boot 应用程序从 JDK 8 升级到 JDK 11,并进行了以下更改:
1.在pom.xml中使用java.version
<properties>
<java.version>11</java.version>
</properties>
Run Code Online (Sandbox Code Playgroud)
2.添加已删除模块的依赖关系:
<!--1.JAF(java.activation)-->
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</dependency>
<!--2.JTA(java.transaction)-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!--3.JAXB(java.xml.bind)-->
<!--API-->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>
<!--Runtime-->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<!--4.JAX-WS(java.xml.ws)-->
<!--API-->
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.2</version>
</dependency>
<!--Runtime-->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.2</version>
</dependency>
<!--5.CommonsAnnotations(java.xml.ws.annotation)-->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
3.添加了以下插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我运行时mvn clean package,出现错误:
compiler message …Run Code Online (Sandbox Code Playgroud) 我的应用程序是一种“网络爬虫”形式,它使用Java Jsoup 库从所需的输入页面加载 HTML 。我最近将我的应用程序平台从 Java 8 升级到了 Java 11。通过这次升级,我收到了一些客户的报告,说他们在尝试加载某些网页的 HTML 内容时收到 SSLHandshakeExceptions。这些出现的网页因设备而异,在某些设备上,我的客户端根本无法加载任何网页(http:// 和 https:// 网页都没有)。
我尝试通过多种方式解决此问题,但无济于事:
在这一点上,我不确定要采取哪些选择,因为我对 SSL、TLS 和 HTTPS 的了解有限。这些错误在 Java 8 中从未发生过,并且在升级到 Java 11 之前一切正常。
根据我的理解,Java 11 关于 SSL 的唯一改变是升级到 TLS 1.3,而之前版本的 Java 依赖于使用 TLS 1.2。
因此,我想强制 Java 11 使用 TLS 1.2 而不是 TLS 1.3,因为我认为这是 SSLHandshakeExceptions 的原因。我该怎么做呢?
我已经在 Ubuntu 机器上运行这个旧的 Caucho Resin (4.0.41) 很多很多年了。我需要退役该服务器,所以我尝试在新的 Ubuntu 18.04.4 服务器上设置resin 4.0.64,经过大量的尝试和摆弄,它正在启动,但最终在早期失败了:
OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "com.caucho.loader.SystemClassLoader"). To use archived non-system classes, this property must be not be set
Error occurred during initialization of VM
java.lang.Error: com.caucho.loader.SystemClassLoader
at java.lang.ClassLoader.initSystemClassLoader(java.base@11.0.6/ClassLoader.java:1989)
at java.lang.System.initPhase3(java.base@11.0.6/System.java:2069)
Caused by: java.lang.ClassNotFoundException: com.caucho.loader.SystemClassLoader
at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@11.0.6/BuiltinClassLoader.java:581)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@11.0.6/ClassLoaders.java:178)
at java.lang.ClassLoader.loadClass(java.base@11.0.6/ClassLoader.java:521)
at java.lang.Class.forName0(java.base@11.0.6/Native Method)
at java.lang.Class.forName(java.base@11.0.6/Class.java:398)
at java.lang.ClassLoader.initSystemClassLoader(java.base@11.0.6/ClassLoader.java:1975)
at java.lang.System.initPhase3(java.base@11.0.6/System.java:2069)
Run Code Online (Sandbox Code Playgroud)
我似乎无法通过谷歌搜索找到任何结果,也找不到任何明显的设置 java.system.class.loader。
有什么建议么?谢谢!
AdoptOpenJDK 的 JRE 11+ 是否与仅使用jlink并添加所有依赖项相同?
Oracle Java 11 及更高版本不附带仅 JRE 的 JDK,因为您可以使用jlink构建自己的 JRE,其中仅包含您需要的系统模块,这就是我在 Windows 和 Linux 上所做的。
然而,对于如何为某些平台(Docker 和 MacOS)合并 jlinked JRE 对我来说并不是那么明显,并且由于 AdoptOpenJDK 不仅为 JDK 还提供了 JRE 的二进制文件,我想我可能只为这些平台使用 JRE。但是,如果我将 JDK 链接起来并包含所有系统模块依赖项,JRE 是否包含我会得到的所有内容?
最近将应用程序从 Oracle Java 9 更新到 AdoptJDk 11.0.6,我现在看到以下代码形式的错误:
public static String convertWikidataUrl(String wikidataUrl)
{
String qPage = wikidataUrl.substring(wikidataUrl.lastIndexOf('/') + 1);
String apiUrl = WIKIDATA_IMAGE_API_URL + qPage;
try
{
URL url = new URL(apiUrl);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
int responseCode = uc.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK)
{
MainWindow.logger.severe(":ResponseCode:"+responseCode);
}
//Everything ok so continue
BufferedInputStream bis = new BufferedInputStream(uc.getInputStream());
JAXBContext jc = getWikidataInitialContext();
Unmarshaller um = jc.createUnmarshaller();
Api api = (Api) um.unmarshal(bis);
if(api.getClaims()!=null
&& api.getClaims().getProperty()!=null
&& api.getClaims().getProperty().getClaim()!=null
&& api.getClaims().getProperty().getClaim().getMainsnak()!=null
&& api.getClaims().getProperty().getClaim().getMainsnak().getDatavalue()!=null)
{ …Run Code Online (Sandbox Code Playgroud) 我使用Springboot构建了一个简单的应用程序。我在部署到Linux服务器时使用的ZGC垃圾收集器使用大量内存..我尝试使用Xmx500m将最大堆内存限制为500MB,但JAVA程序仍然使用了1GB以上。我用G1收集器的时候只用了350MB。不知道为什么,这是JDK11的BUG吗?还是我的启动参数有问题?####运行环境
java -Xms128m -Xmx500m \
-XX:+UnlockExperimentalVMOptions -XX:+UseZGC \
-jar app.jar
Run Code Online (Sandbox Code Playgroud)
这是运行时内存使用情况的截图
堆内存使用情况 https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20201259.png?raw=true
系统内存使用情况 https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20201357.png?raw=true
以下是使用默认垃圾收集器 Java 启动命令时发生的情况
java -Xms128m -Xmx500m \
-jar app.jar
Run Code Online (Sandbox Code Playgroud)
堆内存使用情况 https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20202442.png?raw=true
系统内存使用情况 https://github.com/JoyfulAndSpeedyMan/assets/blob/master/2020-07-13%20202421.png?raw=true
jdk11 默认使用 G1 垃圾收集器。从理论上讲,G1不应该比ZGC更占用内存吗?我为什么不那样使用它?我误解了吗?由于我是JVM的初学者,我不明白为什么。