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

StackOverflow https://stackoverflow.com/questions/21283880

  •  01-10-2022
  •  | 
  •  

Question

I've just switched my java program to use openjdk6 from java 1.7 and now it wont compile. Can anyone help, im a long time developer but newish in 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());
        }
    }
}
Was it helpful?

Solution

Stacktrace is showing that you are trying to run it from inside Intellij IDEA. Injellij IDEA doesn't guarantee that it will work on OpenJDK. A quote from 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.

Try compiling and running from command line. But if you want to keep using Intellij IDEA switch to Oracle JDK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top