Closed ghost closed 4 years ago
Execute
./gradlew jpackage
on your Linux machine.
I asked this question because , I have the following error when I execute this command ./gradlew jpackage
in windows os.
P:\installation\badass-runtime-example-javafx-master>gradlew jpackage
Starting a Gradle Daemon, 1 busy and 1 stopped Daemons could not be reused, use --status for details
> Configure project :
Project : => no module-info.java found
> Task :jpackage
WARNING: Using incubator modules: jdk.incubator.jpackage
Can not find WiX tools (light.exe, candle.exe)
Download WiX 3.0 or later from https://wixtoolset.org and add it to the PATH.
Error: Invalid or unsupported type: [exe]
> Task :jpackage FAILED
FAILURE: Build failed with an exception.
*What went wrong:
Execution failed for task ':jpackage'.
> Process 'command 'C:\Program Files\Java\jdk-14.0.1/bin/jpackage.exe'' finished with non-zero exit value 1
*Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to
get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 26s
7 actionable tasks: 1 executed, 6 up-to-date
Why this error comes?
How can I solve this error?
In the console message says dowload and install the wix then add to path .
But , when I install wix it comes like this
how can I solve this?
See the WiX Toolset documentation:
WiX supports both .NET 3.5 and 4.0 and later. WiX's MSBuild supports requires .NET 3.5, which is not installed by default on Windows 8 and Windows Server 2012 and later. To install the .NET 3.5 feature, go to Control Panel, open Programs and Features, and choose Turn Windows features on or off. In the list of features, choose .NET Framework 3.5 (includes .NET 2.0 and 3.0) and then choose OK.
I successfully build the jpackage .
I want to add terms and conditions in installer .
How can I do this?
You can provide a license file as described here. Using the plugin, you need to add the --license-file
option to installerOptions
:
runtime {
...
jpackage {
...
installerOptions += ['--license-file', 'LICENSE.txt']
}
}
How can I build a jpackage for linux os?
I asked this because, in gradle.build code it contains only for windows os
https://github.com/beryx-gist/badass-runtime-example-javafx/blob/master/build.gradle#L27
Will it work on linux?
Give a solution for this.
If you execute ./gradlew jpackage
on a Linux machine, it will produce a package for Linux. The Windows-specific options you mentioned above are not necessary (and not even available) on Linux. That's why the code in build.gradle applies them only when you execute the build on Windows.
In conclusion, you don't need to make any changes to build.gradle. Just execute ./gradlew jpackage
on a Linux system.
MY project
badass-runtime-example-javafx-master.zip
When I run I have the following error.
07:20:53: Executing task 'Launcher.main()'...
> Configure project :
Project : => no module-info.java found
> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :Launcher.main()
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:900)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3230)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
at org.example.hellofx.Main.start(Main.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
> Task :Launcher.main() FAILED
2 actionable tasks: 1 executed, 1 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Launcher.main()'.
> Process 'command 'C:/Program Files/AdoptOpenJDK/jdk-14.0.2.12-hotspot/bin/java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to
get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
07:20:58: Task execution finished 'Launcher.main()'.
Main.java
package org.example.hellofx;
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().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Try this: badass-runtime-example-javafx-master.zip
I made the following changes:
sample.fxml
from java
to resources
sample.jfxml
: replaced sample.Controller
with org.example.hellofx.Controller
how to set the icon?
Main.java
package org.example.hellofx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.getIcons().add(new Image("ic_launcher.png"));
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
pic :
But , I have the this error
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
How can I solve this errror?
You need to specify the path to your icon:
primaryStage.getIcons().add(new Image("org/example/hellofx/ic_launcher.png"));
I also have the same doubt.
I updated the project to configure a desktop icon.
Note that each platform expects the icon in a different format (.ico
for Windows, .png
for Linux, .icns
for macOS). You need to provide icon files in all these formats in the src/main/resources directory.
The resulting application installers are available here.
I want to make a installer for linux os with this plugin .
But , how can I do this with this plugin ?