Reputation: 113
When I create a GUI form in IntelliJ IDEA, clicking on the Preview menu item creates the Error:
Cannot preview form '.../Main.form' Reason: Class not found: javax.swing.JPanel
However, manually creating a main method in the linked class and running the latter, will create my application window without problems:
public static void main(String[] args) {
JFrame frame = new JFrame("UBPrivacy");
frame.setContentPane(new Main().panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
In my project structure, I have chosen Project SDK: java 9.0.1
In my platform settings, SDK 9.0 has all the necessary paths configured (java.desktop, etc.).
I wonder if this is an IntelliJ IDEA bug or if I somehow misconfigured my classpath, modules or something else. (Since my manual main RUN works successfully.)
Thanks in advance for any help on this topic.
Upvotes: 9
Views: 6350
Reputation: 1
I found the right way is set
"javac2.instrumentation.includeJavaRuntime=true " in build.properties file
you can try it
Upvotes: 0
Reputation: 101
2 Years late and the bug still persists...
For anyone that re-discovered this question. You need to downgrade your project SDK from Java 9,10,11 to Java 8
Upvotes: 10