简体   繁体   English

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

[英]Error changing compiler from JRE1.7 to OpenJdk6 : java.lang.NoSuchFieldError: family

I've just switched my java program to use openjdk6 from java 1.7 and now it wont compile. 我刚刚将Java程序切换为使用来自Java 1.7的openjdk6,现在它无法编译。 Can anyone help, im a long time developer but newish in Java. 任何人都可以提供帮助,我是一位长期的开发人员,但是刚接触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)

"main" looks like “主”看起来像

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 is showing that you are trying to run it from inside Intellij IDEA. Stacktrace显示您正在尝试从Intellij IDEA内部运行它。 Injellij IDEA doesn't guarantee that it will work on OpenJDK. Injellij IDEA不保证它将在OpenJDK上运行。 A quote from https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under 来自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. 不建议使用OpenJDK,因为它具有影响某些用户的已知视觉和性能问题。 Use on your own risk if Oracle JDK has more severe issues on your system. 如果Oracle JDK在系统上有更严重的问题,请您自担风险。

Try compiling and running from command line. 尝试从命令行编译并运行。 But if you want to keep using Intellij IDEA switch to Oracle JDK. 但是,如果要继续使用Intellij IDEA,请切换到Oracle JDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM