Can I have more than one executable file with Java

2019-06-16 04:09发布

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?

1条回答
Evening l夕情丶
2楼-- · 2019-06-16 04:45

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

查看更多
登录 后发表回答