I am trying to develop a sample javafx
application in scala
. I am using sbt-one-jar
for packaging the application. My class MainClass
extends the javafx Application
which in-turn provides the main method. I am able to right-click in the IDE and run the application successfully. However, after creating the executable jar using sbt-one-jar, while trying to run the jar I am getting main class not found error as below :
Exception in thread "main" java.lang.NoSuchMethodException: com.app.MainClass.main([Ljava.lang.String;) at java.lang.Class.getMethod(Unknown Source) at com.simontuffs.onejar.Boot.run(Boot.java:339) at com.simontuffs.onejar.Boot.main(Boot.java:166)
I am giving the Main Class in Build.scala as
mainClass in oneJar := Some("com.app.MainClass")
MainClass.java:
public class MainClass extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Home.fxml"));
Scene scene = new Scene(root, 600, 600);
primaryStage.setTitle("My-App");
primaryStage.setScene(scene);
primaryStage.show();
}
}
If I create another scala application and extending App, I am able to run the created one-jar. How can I get around this problem ?