0

I am learning JavaFX and I m trying to use external libraries (HSQLDB and the corresponding Datamanager GUI Tool) which I imported with Maven. My goal is to open an instance of the Datamanager GUI Tool which is a Swing application.

public class SQLTool extends Application {

@Override
public void start (Stage stage) {
    final SwingNode swingNode = new SwingNode();

    createSwingContent(swingNode);

    StackPane pane = new StackPane();
    pane.getChildren().add(swingNode);

    stage.setTitle("Swing in JavaFX");
    stage.setScene(new Scene(pane, 640, 480));
    stage.show();
    stage.centerOnScreen();
}

private void createSwingContent(final SwingNode swingNode) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            //swingNode.setContent(new JButton("Click me!"));
            **swingNode.setContent(new SwingForm());**
        }
    });
}}


class SwingForm extends JPanel {

public SwingForm(){

    JPanel innerPanel = new JPanel();
    **DatabaseManagerSwing dbms = new DatabaseManagerSwing();**
    innerPanel.add(dbms);
    add(innerPanel);

}}

Getting

java.lang.NoClassDefFoundError: java/sql/SQLException
at com...SQLTool$SwingForm.<init>(SQLTool.java:45)
at com...SQLTool$1.run(SQLTool.java:34)

Thanks for the help!

Marko
  • 47
  • 5
  • well, today is the day off for my crystal ball ;) In other words: details, details, details .. (and might be good to add the swing tag as well, if it involves a swing app) – kleopatra Jun 09 '20 at 11:54
  • okay, better - now the complete stacktrace, please. and maybe add the hsql tag as well, it might be related to those modules and attract expert on those :) – kleopatra Jun 09 '20 at 13:00
  • only those two lines appear! – Marko Jun 09 '20 at 13:29
  • added tag as error message indicates Java module issue. – fredt Jun 09 '20 at 14:20
  • @fredt hmm .. wondering about the javafx.graphicsEmpty, can't recall ever having seen it – kleopatra Jun 09 '20 at 14:22
  • can you add details about your project setup (like what's on the module-path, if it is modular or not ..) – kleopatra Jun 09 '20 at 14:24
  • figured out that the 'sqltool' import was not required since the database manager swing classes included in org.hsqldb.util. – Marko Jun 09 '20 at 14:44
  • project is again starting up but with my posted code I am getting java.lang.NoClassDefFoundError: java/sql/SQLException at those two lines: – Marko Jun 09 '20 at 14:56
  • @kleopatra: I followed the directions given on openjfx.io website for setting up IntelliJ. As I mentioned I used Maven to get the project structure. However I have the module-info.class and using the default generated one. Sorry I am still new to Java! – Marko Jun 09 '20 at 15:06
  • 1
    @kleopatra Those "javafx.xxxEmpty" modules are a consequence from the way they publish to Maven Central. Since JavaFX is platform-specific they have to include classifiers to differentiate between the variants, meaning there's three "real" artifacts per module on Maven Central. However, they also publish a "non-classified" artifact per module which contains nothing except a dummy module-info file. I'm not exactly sure why they do this, but my guess is that it has something to do with the way dependencies are resolved against Maven-based repositories. – Slaw Jun 09 '20 at 16:08
  • @Marko If you're still having problems could you please _create_ a [mre], including your POM, and then [edit] your question to include it. Add the full stack trace as well. Getting a NCDFE for `SQLException` is strange, in my opinion, so an example may help us help you. – Slaw Jun 10 '20 at 13:37

0 Answers0