Intellij idea 什么';Intellij Idea构建的JavaFXApp.jar中缺少什么?

Intellij idea 什么';Intellij Idea构建的JavaFXApp.jar中缺少什么?,intellij-idea,javafx,h2,Intellij Idea,Javafx,H2,我正在使用Intellij Idea 2016.3.5编写一个使用JavaFX和H2数据库的应用程序。我让Intellij创建了一个默认的JavaFX应用程序,并添加了6行我自己的代码: package sample; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.

我正在使用Intellij Idea 2016.3.5编写一个使用JavaFX和H2数据库的应用程序。我让Intellij创建了一个默认的JavaFX应用程序,并添加了6行我自己的代码:

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();

        // my code below
        try {
            Class.forName("org.h2.Driver");
        } catch (ClassNotFoundException e) {
            System.err.println("Class Not Found for h2 Driver");
            System.err.println(e);
        }
    }


    public static void main(String[] args) {
        launch(args);
    }
}
然后我将h2-1.3.176.jar添加到模块依赖项中,因此依赖项如下所示:

1.8 (java version "1.8.0_60")
<Module source>
h2-1.3.176
它抛出一个ClassNotFoundException:org.h2.Driver。但是如果我稍微修改一下命令,它运行得很好:

/usr/lib/jvm/jdk1.8.0_60/bin/java -cp Fubar/out/production/Fubar:/home/opt/h2/bin/h2-1.3.176.jar sample.Main

JavaFXApp.jar遗漏了什么?如何构建jar文件并在类路径中运行h2-1.3.176.jar?

请参阅。您不能将
-cp
-jar
一起使用。见:
/usr/lib/jvm/jdk1.8.0_60/bin/java -cp Fubar/out/production/Fubar:/home/opt/h2/bin/h2-1.3.176.jar sample.Main