0

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.

Dov
  • 8,000
  • 8
  • 46
  • 75
  • Which version of Netbeans are you trying to use? – Stephen C Aug 24 '19 at 12:42
  • Product Version: Apache NetBeans IDE 10.0 (Build 20190125-debian-10.0) Java: 11.0.4; OpenJDK 64-Bit Server VM 11.0.4+11-post-Ubuntu-1ubuntu219.04 Runtime: OpenJDK Runtime Environment 11.0.4+11-post-Ubuntu-1ubuntu219.04 System: Linux version 5.0.0-25-generic running on amd64; UTF-8; en_US (nb) User directory: /home/user/.netbeans/10.0 Cache directory: /home/user/.cache/netbeans/10.0 – Dov Aug 24 '19 at 12:45
  • 1
    Your problem is probably this then: https://stackoverflow.com/a/57014904/139985 – Stephen C Aug 24 '19 at 13:36

0 Answers0