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?
Asked
Active
Viewed 447 times
9
-
When you say binary are you talking about and executable file? – SedJ601 Sep 27 '17 at 13:12
-
Yes, I mean am executable file – Pablo Fernandez Sep 27 '17 at 13:13
-
Is this not a matter of just a right click copy? – SedJ601 Sep 27 '17 at 13:13
-
Right click copy is not part of a build system. – Pablo Fernandez Sep 27 '17 at 13:14
-
This is probably out of my league. – SedJ601 Sep 27 '17 at 13:16
-
@Pablo http://winrun4j.sourceforge.net/ – RïshïKêsh Kümar Oct 06 '17 at 18:17
1 Answers
4
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 ;)

Pablo Fernandez
- 279,434
- 135
- 377
- 622

FibreFoX
- 2,858
- 1
- 19
- 41
-
2Just a note: when you have any question, you might want to open an issue in the github-project or even get in direct contact via e-mail. This is often faster, but I can understand that SO is an excellent "research"-location ;) – FibreFoX Sep 29 '17 at 18:33
-
Suggestion:- [Example](https://github.com/FibreFoX/javafx-gradle-plugin/blob/master/README.md#example-buildgradle) misses that ideal line of documentation in that case. – Naman Oct 02 '17 at 07:46
-
Thank you @FibreFoX. These types of answers are rare and it should be SO should strive for. – Pablo Fernandez Oct 24 '17 at 08:20