Copy Maven dependency files and runtime in jpackage - javafx

I have a JavaFX project with dependencies on SQLite and POI, so I used maven-dependency-plugin to copy all dependencies in target\lib folder. That folder contains about 21 dependencies common-codecs, curvesapi, javafx-base, javafx-fxml... etc.
To create a jpackage I'm using jpackage-maven-plugin to create an installer. I have jmods folder copied to java.home. The POM is as follows:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.39.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<launcher>App</launcher>
<mainClass>com.example.App</mainClass>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
</execution>
<execution>
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
</options>
</configuration>
</execution>
<execution>
<id>ide-debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
</configuration>
</execution>
<execution>
<id>ide-profile</id>
<configuration>
<options>
<option>${profiler.jvmargs.arg1}</option>
<option>${profiler.jvmargs.arg2}</option>
<option>${profiler.jvmargs.arg3}</option>
<option>${profiler.jvmargs.arg4}</option>
<option>${profiler.jvmargs.arg5}</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<name>ExampleFX</name>
<appVersion>${project.version}</appVersion>
<icon>${basedir}/icon.ico</icon>
<vendor>Myself</vendor>
<destination>Runtime</destination>
<modulePaths>
<modulePath>C:\Program Files\Java\jmods</modulePath>
<modulePath>${project.build.directory}/classes</modulePath>
</modulePaths>
<module>com.example/com.example.App</module>
<runtimeImage>${java.home}/lib</runtimeImage>
<winDirChooser>true</winDirChooser>
<winShortcut>true</winShortcut>
<winConsole>true</winConsole>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>19</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
This command neither packages the lib folder in the installer, nor does it properly copies JVM, as on running the program, it gives Failed to find JVM in "C:\Program Files\Example\runtime" directory. error. Any help appreciated.
EDIT
Changed some parameters:
from<runtimeImage>${java.home}/lib</runtimeImage> to <runtimeImage>${java.home}</runtimeImage>,
added module path <modulePath>${project.build.directory}/lib</modulePath>
Now the app fails to find modules (dependencies) which are present in ${INSTALLDIR}/app/mods. Trying to add these modules require I remove runtimeImage parameter. If I do so:
<addModules>javafx.fxml,javafx.controls,
org.apache.poi.ooxml,org.apache.poi.poi,org.xerial.sqlitejdbc,SparseBitSet,
org.apache.commons.compress,org.apache.commons.codec,org.apache.commons.collections4,
org.apache.commons.io,com.github.virtuald.curvesapi,commons.math3,
org.apache.commons.collections4,org.apache.xmlbeans</addModules>
I always get error regarding any module randomly:
jlink failed with: Error: automatic module cannot be used with jlink: commons.math3 from file:///C:/Users/MY/Documents/NetBeansProjects/Example/target/lib/commons-math3-3.6.1.jar
module-info
module com.example{
requires javafx.controls;
requires javafx.fxml;
requires javafx.base;
requires javafx.graphics;
requires java.logging;
requires java.base;
requires java.sql;
requires org.apache.poi.poi;
requires org.apache.poi.ooxml;
requires org.apache.commons.codec;
requires org.apache.commons.collections4;
requires org.apache.commons.compress;
requires org.apache.commons.io;
requires commons.math3;
requires com.github.virtuald.curvesapi;
requires org.apache.logging.log4j;
requires SparseBitSet;
requires org.xerial.sqlitejdbc;
requires org.apache.xmlbeans;
opens com.example to javafx.fxml;
exports com.example;
}

Use JPackageScriptFX. Here's how to use it:
(I'll refer to JPackageScriptFX as JPS and your project as Example)
Copy your Example project folder inside JPS's folder.
Open JPS's POM, and go to <modules> section. Remove all existing module entries (jpackagefx-main,jpackagefx-module1,jpackagefx-module2). Write <module>Example</module> instead.
Change groupId to Example's groupId.artifactId.
Open Example's POM. Write <packaging>jar</packaging> beneath <version> tag.
Copy jpackagefx-main's maven-dependency-plugin from its POM and copy it to Example's POM.
Write <configuration><mainClass>com.example.App</mainClass></configuration> in javafx-maven-plugin if it isn't there already.
Copy whole of the <profiles> section from jpackagefx-main and copy it to Example's POM.
Rename ${client.version} to ${project.version} in <APP_VERSION> and <PROJECT_VERSION> (This is required especially in the case of Linux, otherwise the jpackage will fail in final stages (dpkg-deb returns with error code 2)).
Create a new class file named AppLauncher, and write following code in it:
package com.example
public class AppLauncher{
public static void main(String[] args){
App.main(args);
}
}
Depending on your platform (Windows, Linux, Mac) copy the build_app_linux.sh, build_app_mac.sh or build_app_windows.bat file inside Example's project folder. I'll refer to the linux version in the next steps, you can find appropriate lines in other platform files.
Line 13, Change MAIN_JAR="main-ui-... to MAIN_JAR="Example-... or whatever the name of your Jar file is (You can find Jar filename by building the project and simply looking its name in target folder).
Line 47, change class path to target/classes/com/Example/App.class
Line 63, append modules you want in your project (in your case, ,java.sql).
Line 92, Change to whatever name you want to give. You can also use quotes " to give space in the name.
Line 93, set --main-class to com.example.AppLauncher.
Line 97, optinally, set your own icon by modifying this line.
For Windows, additionally change line 40 to --print-module-deps target\classes\com\example\App.class > temp.txt.
Open pom.xml[parent] using Whatever IDE. I'm using netbeans, so I can clean and build the project by pressing SHIFT+F11.
If there's no error, then your installer will be present in target\installer

Related

I created a JavaFX App and I get an the following error: "JavaFX runtime components are missing, and are required to run this application" [duplicate]

I'm trying to create a JFX11 self-containing jar using maven dependencies. From the research I've done, it seems the best way to do this is through the maven shade plugin. However, When I run it, I get the this error:
Error: JavaFX runtime components are missing, and are required to run this application
I don't understand why this is happening. What am I messing up? Is there a better way to do this? I've also tried the maven assembly plugin with the same message.
pom file for reference
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Application</groupId>
<artifactId>Main</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpaceRunner</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>10</release>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>Application.Main</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>
Application.Main
</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Application.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
UPDATE 10/2021
Since JavaFX 16 a warning is displayed when JavaFX doesn't run on the module path, which is the case of an uber/fat jar:
$ java -jar myFatJar-1.0-SNAPSHOT.jar
Oct 02, 2021 1:45:21 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module #14c24f4c'
Also, you get a warning from the shade plugin itself:
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
While these warnings can be initially ignored, there is a reason for them.
As explained in this CSR:
JavaFX is built and distributed as a set of named modules, each in its own modular jar file, and the JavaFX runtime expects its classes to be loaded from a set of named javafx.* modules, and does not support loading those modules from the classpath.
And:
when the JavaFX classes are loaded from the classpath, it breaks encapsulation, since we no longer get the benefit of the java module system.
Therefore, even this widely accepted answer explains how can an uber/fat jar can be created on Maven projects, its use is discouraged, and other modern alternatives to distribute your application, like jlink, jpackage or native-image, should be used.
ORIGINAL ANSWER
This answer explains why a fat/uber jar fails on JavaFX 11. In short:
This error comes from sun.launcher.LauncherHelper in the java.base module. The reason for this is that the Main app extends Application and has a main method. If that is the case, the LauncherHelper will check for the javafx.graphics module to be present as a named module. If that module is not present, the launch is aborted.
And already proposes a fix for Gradle.
For Maven the solution is exactly the same: provide a new main class that doesn't extend from Application.
You will have new class in your application package (bad name):
// NewMain.java
public class NewMain {
public static void main(String[] args) {
Main.main(args);
}
}
And your existing Main class, as is:
//Main.java
public class Main extends Application {
#Override
public void start(Stage stage) {
...
}
public static void main(String[] args) {
launch(args);
}
}
Now you need to modify your pom and set your main class for the different plugins:
<mainClass>application.NewMain</mainClass>
Platform-specific Fat jar
Finally, with the shade plugin you are going to produce a fat jar, on your machine.
This means that, so far, your JavaFX dependencies are using a unique classifier. If for instance you are on Windows, Maven will be using internally the win classifier. This has the effect of including only the native libraries for Windows.
So you are using:
org.openjfx:javafx-controls:11
org.openjfx:javafx-controls:11:win
org.openjfx:javafx-graphics:11
org.openjfx:javafx-graphics:11:win <-- this contains the native dlls for Windows
org.openjfx:javafx-base:11
org.openjfx:javafx-base:11:win
Now, if you produce the fat jar, you will bundle all those dependencies (and those other regular third party dependencies from your project), and you will be able to run your project as:
java -jar myFatJar-1.0-SNAPSHOT.jar
While this is very nice, if you want to distribute you jar, be aware that this jar is not cross-platform, and it will work only on your platform, in this case Windows.
Cross-Platform Fat Jar
There is a solution to generate a cross-platform jar that you can distribute: include the rest of the native libraries of the other platforms.
This can be easily done, as you just need to include the graphics module dependencies for the three platforms:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>mac</classifier>
</dependency>
</dependencies>
Size
There is a main issue with this approach: the size. As you can see in this other answer, if you use the WebView control, you will be bundling around 220 MB due to the WebKit native libraries.

Dependencies in fat jar not working outside of IDE (Java 8)

So im working on this JavaFx application (Java 8) which copies a .xlsx file and fills it with data from a .txt-file, for this I use the apache poi dependency. I have successfully build a fat jar through the maven-assembly-plugin. Here my pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<mainClass>sample.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
I build it with:
mvn clean compile assembly:single
The application and its dependencies work fine when I run the main.java in IntelliJ, also the built fat jar starts and works fine when I run it through IntelliJ (performes all functions without a problem).
Only when I start my fat jar outside of the IDE, through a cmd-file (to start the JavaFx application), I'm encountering problems. It starts and loads the .txt-file just fine, but at the point where it's supposed to use the dependency and create a worksheet the program does nothing. Here's what I run in .cmd-file:
start javaw -jar ExcelConverter-1.0-jar-with-dependencies.jar
I've tried building it with various other plugins (shade etc), all seem to have the same problem.
I've also tried building it through intelliJ as an artifact, same issue.
Dependency order is also not an issue as I only use one.
use maven shade plugin for this .check http://maven.apache.org/plugins/maven-shade-plugin/index.html.
below is the sample
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
The problem wasn't the plugins or dependencies not working but that the apache-poi dependency was too memory intensive and thus my JVM ran out of memory. The IntelliJ IDE I've installed uses JVM 64-bit by default, my system on the other hand was using a 32-bit version. I was able to update my JVM to 64 bit and getting it to work fine.

Payara Micro: How to log with slf4j (or log4j2)?

I'm using Payara Micro (bundled ueberjar) for a recent project, but I have difficulties with logging. Seems like Payara Micro uses JUL by default, which does not suit my needs. I'd like to use Log4J 2 instead, preferably through slf4j. Unfortunately, I couldn't find much information. To start with, I'd like refer to the following link...
https://blog.payara.fish/the-basics-of-logging-in-payara-server
... which says: "Payara Micro can also be adjusted to use other logging frameworks like Logback and Log4J2." Sounds great, but the only source that deals with that matter seems to be the following example project: https://github.com/hei1233212000/payara-micro-log4j2. Yet it is from 2017 and seems to be outdated as it doesn't use the payara micro maven plugin. Still, I guess the point is:
add the necessary logging jars to the bundle
adjust Manifest file by adding the jars to the classpath
use the SLF4JBridgeHandler for Payara Micro
I tried my luck adding the jars as customJars via the payara micro maven plugin, which indeed resulted in a bundled jar containing those libs under MICRO-INF/lib. From what I read, the jars should also be on classpath, though they don't appear in the Manifest file. Also, I added the logging.properties tih the following simple content under src/main/resources:
handlers=org.slf4j.bridge.SLF4JBridgeHandler
Now, if I run the bundled jar, it says Can't load log handler "org.slf4j.bridge.SLF4JBridgeHandler", followed by an ugly stacktrace. Yet the class org.slf4j.bridge.SLF4JBridgeHandler is in one of the jars I added. I already experimented with the groovy script from the example I linked above to edit the Manifest file, but I couldn't figure out how to set it up properly. I mean, the script worked and I get an edited Manifest file, but it is not added to the bundled jar - I guess my timing is bad. Not to mention that this is kind of hackish as the author of the example said.
Interestingly, if I don't add the logging.properties to the jar, thus leaving Payara Micros logging setup untouched, I can reroute logging output from 3rd party libraries (such as hibernate) coming with Payara Micro while its own logs are logged to the console. Yet that's not my goal as I am more interested in the latter logs.
So, I'd be thankful if someone could give me a hand. Thanks for reading. For completeness, here is my pom.xml (I am using the package profile, the other is for cucumber tests only):
<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>de.kepes.payara-micro</groupId>
<artifactId>payara-micro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<skipTests>true</skipTests>
<payara-micro.version>5.194</payara-micro.version>
<payara-micro.plugin.version>1.0.6</payara-micro.plugin.version>
<jakarta.version>8.0.0</jakarta.version>
<maven-failsafe.plugin.version>2.22.2</maven-failsafe.plugin.version>
<cucumber.version>5.4.0</cucumber.version>
<websocket.version>1.4.0</websocket.version>
<log4j.version>2.13.0</log4j.version>
<slf4j.version>1.7.30</slf4j.version>
</properties>
<profiles>
<profile>
<id>package</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>${payara-micro.plugin.version}</version>
<executions>
<execution>
<id>bundle</id>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
<execution>
<id>start</id>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
<configuration>
<useUberJar>true</useUberJar>
<deployWar>true</deployWar>
<payaraVersion>${payara-micro.version}</payaraVersion>
<customJars>
<customJar>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</customJar>
<customJar>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</customJar>
<customJar>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</customJar>
<customJar>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</customJar>
<customJar>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</customJar>
</customJars>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>test</id>
<properties>
<skipTests>false</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>${payara-micro.plugin.version}</version>
<executions>
<execution>
<id>pre-integration-payara</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>post-integration-payara</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<payaraVersion>${payara-micro.version}</payaraVersion>
<deployWar>true</deployWar>
<contextRoot>/</contextRoot>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakarta.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>${websocket.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
this isn't possible just by adding logging libraries as custom JARs as logging is initialized before those libraries are loaded.
However, there's a solution how to use alternative logging libraries. You need to run Payara Micro in a different way. If you put it on the classpath and run the Payara Micro main class directly, you can put custom logging libraries on the classpath too and they will be picked up at boot time, before logging is initialized. If you have payara-micro.jar, slf4j.jar, log4j.jar and jul-to-slf4j.jar in the current directory, you can launch Payara Micro like this:
java -cp ./payara-micro.jar:slf4j.jar:log4j2.jar:jul-to-slf4j.jar fish.payara.micro.PayaraMicro some.war
Alternatively, you can move those logging JARs to a subdirectory lib and shorten the command line:
java -cp "./payara-micro.jar:lib/*" fish.payara.micro.PayaraMicro some.war
You can pass the same arguments to the PayaraMicro class which are accepted by the Payara Micro JAR.

Javafx application doesnt work after install

I'm creating new JavaFX application. I have done it, now i need to build exe file. After build I have installed it, then i launch the program and nothing. There is no application window, it was showing only in task manager...
Project have no errors, just some warrnings. I'am using http connections in it, maybe i need to declare permissions or something? Where can i do it if it's a problem?
I've tried to generate new build.xml, include newest sdk/jre, installed new version of java in my computer.
Java cannot build an exe file by itself. Every client who needs to run the application needs an appropriate JRE installed to run the application. Therefore you would need some software that packages the jar and the JRE into an exe file to install it or packages the jar and JRE into one single exe file which executes your program.
It has nothing to do with your http connections or build.xml.
However your app will run when you call it via the command line java -jar YOUR_APP.jar
If you just want to run your program by double clicking the jar file (and not build an exe), you can take a look at the following paragraphs.
For Maven
If you are building your project with Maven you can try the following POM settings to have your program be executable from the jar file (double click the jar file to start the JavaFX application):
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.4</version>
<configuration>
<mainClass>PATH TO YOUR MAIN CLASS (e.g. com.foo.Main)</mainClass>
<allPermissions>true</allPermissions>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>PATH TO YOUR MAIN CLASS (e.g. com.foo.Main)</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
I recommend you exporting it as an jar file because it can be excecuted on linux, too and it fixes your problem because it can contain all the data you need just like fxmls!
Just export your project as an runnable jar and this window will appear!
Click here! I don't have enough reputation (but it works ;) )
And now you are finished!

How to set custom icon for javafx native package icon on Windows

I am trying to chance the icon of the exe file while creating native bundling of javafx packaging.
I tried adding icon into pom.xml but till it wont work out for me as it gives default icon
Using Intellij IDEA IDE which contain an Pom.xml creating an package by command = mvn jfx:build-native
Here is my pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<mainClass>com.demoApp.testapp.testApplication</mainClass>
<!-- only required if signing the jar file -->
<keyStoreAlias>example-user</keyStoreAlias>
<keyStorePassword>example-password</keyStorePassword>
<permissions>
<permission>all-permissions</permission>
</permissions>
<icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I have added an icon path into pom.xml ${basedir}/src/main/resources/images/logoIcon.ico
that will run while native package execute but it wont work out for me
Is any other way to do it ?
Please suggest.
i tried fx tags in pom.xml using ant,here is my changes in pom.xml
<properties>
<javafx.tools.ant.jar>${env.JAVA_HOME}\lib\ant-javafx.jar</javafx.tools.ant.jar> </properties>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>create-launcher-jar</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target xmlns:fx="javafx:com.sun.javafx.tools.ant">
<taskdef
uri="javafx:com.sun.javafx.tools.ant"
resource="com/sun/javafx/tools/ant/antlib.xml"
classpath="${javafx.tools.ant.jar}"/>
<fx:application id="fxApp"
name="${project.name}"
mainClass="com.precisionhawk.flightplanner.FlightPlannerApp"/>
<fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
<fx:application refid="fxApp"/>
<fx:fileset dir="${project.build.directory}/classes"/>
</fx:jar>
<attachartifact file="${project.build.directory}/${project.build.finalName}-launcher.jar"
classifier="launcher"/>
<fx:deploy>
<fx:info>
<fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>
</fx:info>
</fx:deploy>
</target>
</configuration>
</execution>
</executions>
</plugin>
but it wont work out..
I just struggled with the same issue using Zonsky's great javafx-maven-plugin. As of version 1.5, which you also were using, the src/main/deploy directory will be added to the classpath. The icon you want to use could be added there and it will be available on the classpath for the native builder!
I added src/main/deploy/package/windows/myapp.ico there and it finally worked :)
For you:
Create src/main/deploy/package/windows/ folder
Add icon with name ${project.build.finalName}.ico
Run mvn jfx:build-native
I haven't played with it extensively - just got it to work and wanted to share. So if you want to use icon with different name, I don't know how. Not yet at least. The <icon>...</icon> section in the config section seems to be for webstart, so I haven't been using it.
Hope you get it to work!
You need to look at the logging while building a native app. That will tell you where the installer looks for the icon files and with wich name. For the default Windows native app it looks in ./package/windows/'appname'.ico
Can't remember where 'appname' comes from, but just look at the logging while building, it will tell you. (I use the Ant targets called from my pom btw)
you can do this:
`<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>YourCompany</vendor>
<mainClass>com.alan344.MapperGenApplication</mainClass>
<appName>mybatis-friend</appName>
<bundleArguments>
<icon>${project.basedir}/src/main/resources/image/icon.ico</icon>
</bundleArguments>
</configuration>
</plugin>`

Resources