I'm using the JavaFX Gradle plugin to build my JavaFX application. Is it possible to have more than one executable built with different main classes? If so, how?
JavaFX is a Java library that consists of classes and interfaces that are written in native Java code. The APIs are designed to be a friendly alternative to Java Virtual Machine (Java VM) languages, such as JRuby and Scala.
The recommended way to package JavaFX applications is to use a collection of Ant tasks (ant-javafx. jar), provided with the JavaFX SDK and also with JDK 7 Update 6 or later. NetBeans IDE uses these Ant tasks to package JavaFX projects. Embedded packaging support in NetBeans IDE covers most of the typical use cases.
JavaFX extends the power of Java by allowing developers to use any Java library within JavaFX applications. This way developers can expand their capabilities in Java and make use of the presentation technology that JavaFX provides to build engaging visual experiences.
This is possible, as the underlying javapackager
does support this.
As I'm understanding you correct, you have a project, where you have multiple entry-points and now you want to create native launchers/binaries for each of that entry-point. This is called "secondary launcher" inside the gradle plugin and even inside the javapackager
.
To create multiple executables with the same bundle, just add this inside your buildfile:
jfx {
// ... normal configuration ...
// your secondary entry points, each will create a native executable (and one .cfg-file for each)
secondaryLaunchers = [
// second executable
[
appName: 'somethingDifferent'
// will create the same executable, just with a different name (so this is demo-purpose only)
],
// third executable
[
appName: 'somethingDifferent2',
// specify your different entry-point
mainClass: 'your.different.entrypoint.MainApp'
// other possible entries: "jfxMainAppJarName", "jvmProperties", "jvmArgs", "userJvmArgs", "nativeReleaseVersion", "needShortcut", "needMenu", "vendor", "identifier"
]
]
}
Disclaimer: I'm the creator of the JavaFX Gradle plugin ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With