On Ubuntu 19, I installed netbeans and tried to build a minimal swing demo that opens a window. Errors shown in comments
package testswing; //cannot access java.lang
import javax.swing.*;
public class TestSwing extends JFrame { // cannot find symbol JFrame
public TestSwing() {
super("test");
setSize(1000,800);
setVisible(true);
}
public static void main(String[] args) {
new TestSwing();
}
}
There is nothing wrong with the code, which can be compiled at the command line:
javac TestSwing.java
java TestSwing
here is what Java reports
java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)
Netbeans on the project properties reports using jdk11, but nothing is showing in the classpath. Is this the problem? It seems crazy that I would suddenly have to add the java libraries to the path, this has never been necessary in the past. If so, how would this be done?
I have also tried adding JDK-8 to /opt. There might be some libraries that don't work in JDK11 though it might be more of this mess. When I add jdk1.8 to Netbeans, then the code can compile, but in the Run menu, it still defaults to jdk11. I can select jdk1.8, but every time the run options come up, it is back to jdk11 so running the code never works under netbeans even with an older jdk.