javafx-maven-plugin icon indicating copy to clipboard operation
javafx-maven-plugin copied to clipboard

Cannot find .jar in custom JRE

Open wunmiji opened this issue 5 years ago • 4 comments

Hello, javafx-maven-plugin is a good plugin... But after creating and runing custom jre several times I still cannot find the jar file anywhere in the target folder... After some search i use mvn package to get the .jar out... But I still cannot open the jar file by double clicking and also I cant find the libs(javafx controls, fxml) just as it was in javafx8...

Project Name : hellofx Project Link : https://github.com/openjfx/samples/tree/master/IDE/IntelliJ/Modular/Maven/hellofx

wunmiji avatar Feb 06 '20 12:02 wunmiji

When we use jlink we create a custom JRE image which put all modules (jars included) into a big file located in $CUSTOM_JRE_IMAGE/lib/modules folder. So, your project code, its dependencies to libs and its dependencies to JDK modules are packaged in the modules file, all of them.

This behavior is foreign to the javafx-maven-plugin.

Aside of the JRE image generated by jlink if you want to get all dependencies JARs you must to use the maven-dependencies-plugin.

betanzos avatar Feb 06 '20 18:02 betanzos

Okay I understand that part of JRE now... Big Thanks! I tried running the jar file still not working... My cmd is below

C:\Users\Adewunmi Omobolaji\Documents\Intellij IDEA\Hellofx\target>hellofx\bin\launcher

...working

C:\Users\Adewunmi Omobolaji\Documents\Intellij IDEA\Hellofx\target>java -jar hellofx-1.0-SNAPSHOT.jar

no main manifest attribute, in hellofx-1.0-SNAPSHOT.jar

...not working

wunmiji avatar Feb 07 '20 07:02 wunmiji

If you want to run the JAR via java -jar (this is via CLASSPATH) you need to define the main class in JAR MANIFEST (look at this for examples). Needed dependencies can be defined via MANIFEST too or in run time by using java -cp libs\ -jar ..... (-cp define the application CLASSPATH).

betanzos avatar Feb 07 '20 15:02 betanzos

Thanks for the quick reply... The jar fle is not runing. This is my pom.xml below

` <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>org.openjfx</groupId>
<artifactId>hellofx</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>hellofx</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.release>11</maven.compiler.release>
    <javafx.version>11</javafx.version>
</properties>

<organization>
    <!-- Used as the 'Vendor' for JNLP generation -->
    <name>Your Organisation</name>
</organization>

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>${javafx.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <release>${maven.compiler.release}</release>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.4</version>
            <configuration>
                <release>${maven.compiler.release}</release>
                <jlinkImageName>hellofx</jlinkImageName>
                <launcher>launcher</launcher>
                <mainClass>hellofx/org.openjfx.Launcher</mainClass>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>-cp</classpathPrefix>
                        <mainClass>hellofx/org.openjfx.Launcher</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

`

wunmiji avatar Feb 07 '20 20:02 wunmiji