Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have more than one executable file with JavaFX native building tool?

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?

like image 321
pupeno Avatar asked Sep 27 '17 12:09

pupeno


People also ask

Is JavaFX a library or framework?

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.

How do I package a JavaFX application?

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.

What is the main purpose of latest JavaFX release?

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.


1 Answers

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 ;)

like image 130
FibreFoX Avatar answered Sep 19 '22 13:09

FibreFoX