The assembled project is launched on Windows but not launched on UNIX
-
There is a code that represents a simple window using JavaFX. Collected with Maven, jar's getting on Windows, but Ubuntu's not starting.
Error: Could not find or load main class ru.quwantoq.sample.Main
I put pom.xml down there.
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>ru.quwantoq</groupId> <artifactId>sample</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>ru/quwantoq/sample/Main</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>com.zenjava</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>8.1.2</version> <configuration> <mainClass>ru/quwantoq/sample/Main</mainClass> </configuration> </plugin> </plugins> </build>
</project>
Class
Main
package ru.quwantoq.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().getClassLoader().getResource("sample.fxml")); primaryStage.setTitle("Hello World"); primaryStage.setScene(new Scene(root, 300, 275)); primaryStage.show(); } public static void main(String[] args) { launch(args); }
}
Class
Controller
package ru.quwantoq.sample;
public class Controller {
}
♪
resources
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?><?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="ru.quwantoq.sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>
-
Experiments revealed that there was no JavaFX in OpenJDK. If it is collected and launched through Oracle JDK, it's working, but in an attempt to launch a collected jar nick through the OpenJDK, this error occurs. When compiling the OpenJDK, the error already occurs at the compilation stage:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project sample: Compilation failure: Compilation failure: [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[3,26] package javafx.application does not exist [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[4,19] package javafx.fxml does not exist [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[5,20] package javafx.scene does not exist [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[6,20] package javafx.scene does not exist [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[7,20] package javafx.stage does not exist [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[9,27] cannot find symbol [ERROR] symbol: class Application [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[12,23] cannot find symbol [ERROR] symbol: class Stage [ERROR] location: class ru.quwantoq.sample.Main [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[11,5] method does not override or implement a method from a supertype [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[13,9] cannot find symbol [ERROR] symbol: class Parent [ERROR] location: class ru.quwantoq.sample.Main [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[13,39] cannot find symbol [ERROR] symbol: method getClass() [ERROR] location: class ru.quwantoq.sample.Main [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[13,23] cannot find symbol [ERROR] symbol: variable FXMLLoader [ERROR] location: class ru.quwantoq.sample.Main [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[15,35] cannot find symbol [ERROR] symbol: class Scene [ERROR] location: class ru.quwantoq.sample.Main [ERROR] /media/sf__Shared_Folder/project/src/main/java/ru/quwantoq/sample/Main.java:[21,9] cannot find symbol [ERROR] symbol: method launch(java.lang.String[]) [ERROR] location: class ru.quwantoq.sample.Main [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The computer can't find JavaFX components.
Maybe we should use Oracle JDK to work with JavaFX.
Supplement
When specifically considered Ubuntu 15.10it's for the annexes. JavaFX a package. OpenJFX:
sudo apt-get install openjfx
After that, everything is going to work.
I wonder what IntelliJ IDEA It's not automatic. It's not packaged. OpenJFX♪ For it to take a change, either add jar-packets with classes manually or simply remove SDK and re-establish. I recall that SDK constructions are here:
File - Modern Project Structure - constituent Platform Settings - Federal SDKs
P.S. I wonder what's in. Linux Mint 17.2 package OpenJFX No.