N
N
Neonoviiwolf2016-08-19 14:18:15
Java
Neonoviiwolf, 2016-08-19 14:18:15

Poke me a finger how to build a javaFx application?

Good!
Here I rummage in Google, but I can’t find how to build an application from javaFx in IntelliJ IDEA. I somehow did something and started building 3 files, but there is no sense from them, one launches the terminal and turns off, the second - something java writes
ps. the application contains a gui, if it is important
4710140a92fb429ab440448a6235db88.png86a12357dfdd4da2b1863d48409fc3c9.png
I understand that the application is not signed, but how to sign it? or I do not understand correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vorh, 2016-08-19
@Neonoviiwolf

1) Create a Maven project
2) Specify in pom.xml that we will build the jar:

<groupId>Example</groupId>
    <artifactId>Example</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

2) Connect the plugin javafx-maven-plugin
<build>
        <plugins>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <mainClass>тут пишем путь до вашего главного класса </mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

3) We build the project with the mvn clean jfx:jar command, it will build the project in duplicate or select it through the Maven Projects menu.
5) Go to target /jpx/app - here lies the jar itself, and in target/jfx/app/lib - the libraries that were used in the project, when distributing, give both the jar and the “target/jfx/app/lib” folder " which should be next to the executable file.

N
Neonoviiwolf, 2016-08-20
@Neonoviiwolf

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
  at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
  at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Location is required.
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
  at Main.start(Main.java:35)
  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
  at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
  at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
  ... 1 more

swears at root = FXMLLoader.load(getClass().getResource("sample.fxml"));
I don't understand its
contents pom
<?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>fineFood</groupId>
    <artifactId>fineFood</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <mainClass>Main</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.3</version>
        </dependency>
    </dependencies>
</project>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question