gpt4 book ai didi

java - 将编译器从 JRE1.7 更改为 OpenJdk6 时出错 : java. lang.NoSuchFieldError: family

转载 作者:行者123 更新时间:2023-12-01 13:35:53 25 4
gpt4 key购买 nike

我刚刚将我的 java 程序从 java 1.7 切换为使用 openjdk6,现在它无法编译。谁能帮忙,我是一名资深开发人员,但对 Java 很陌生。

Abnormal build process termination: 
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at org.jetbrains.jps.cmdline.Launcher.main(Launcher.java:51)
Caused by: java.lang.NoSuchFieldError: family
at sun.nio.ch.ServerSocketChannelImpl.initIDs(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.<clinit>(ServerSocketChannelImpl.java:346)
at sun.nio.ch.SelectorProviderImpl.openServerSocketChannel(SelectorProviderImpl.java:51)
at java.nio.channels.ServerSocketChannel.open(ServerSocketChannel.java:92)
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:89)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:140)
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:45)

“主”看起来像

import app.Controller;
import quickfix.ConfigError;
import static libs.Library.log;

public class Main
{
public static void main(String[] args)
{
try {
log("Starting...");

Class.forName("com.mysql.jdbc.Driver").newInstance();

Controller client = new Controller();
client.login();

synchronized (client)
{
try {
client.wait();
}
catch (Exception e) {}
}
}
catch (ConfigError e) {
log("Config error: " + e.getMessage());
}
catch (Exception e) {
log(e.getMessage());
}
}
}

最佳答案

Stacktrace 显示您正在尝试从 Intellij IDEA 内部运行它。 Injellij IDEA 不保证它可以在 OpenJDK 上运行。引用自https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

Using OpenJDK is not recommended, it has known visual and performance problems that affect some users. Use on your own risk if Oracle JDK has more severe issues on your system.

尝试从命令行编译并运行。但如果您想继续使用 Intellij IDEA,请切换到 Oracle JDK。

关于java - 将编译器从 JRE1.7 更改为 OpenJdk6 时出错 : java. lang.NoSuchFieldError: family,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21283880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com