intellij-ideajavafx

Intellij IDEA generating html y jnlp for java fx artifact


Why when I'm generating an artifact for a javafx application using Intellij IDEA, besides the .jar, it generates a .html and a .jnlp file?, are those two necessary for the application to work, if not is there a setting I can change in order to don't create those anymore?


Solution

  • Update 2025

    The current Idea JavaFX Artifact tab (as of early 2025) is outdated and does not work with modern Java distributions. It was built for earlier JavaFX versions, such as the one originally embedded in Oracle JDK 8 that relied on JavaFX ant tasks and a tool named javafxpackager which is no longer available.

    When you try to use the Idea JavaFX Artifact with a modern Java/JavaFX distribution (e.g. 23.x), it will output:

    Java FX Packager: Can't build artifact - fx:deploy is not available in this JDK 
    

    The replacement for the JavaFXPackager is the jpackage tool. As far as I know, currently Idea does not provide direct artifact support for using the jpackage tool. The tool can instead be used directly from the command line or shell scripts or by build tool plugins for maven and gradle. The jpackage tool does not generate HTML and JNLP code for the packaged artifact as that kind of deployment relied on Java Webstart technology which is no longer part of the OpenJDK project.


    Original Answer

    Files Required for Various JavaFX Execution Modes

    it generates a .html and a .jnlp file?, are those two necessary for the application to work

    The files required for deployment depend on the execution mode of your application.

    1. If your application is embedded in a browser (e.g. executes via the Java plugin like a traditional Java applet), then you require all of the .html, .jnlp and .jar files.
    2. If your application is launched from a browser via Webstart using the Java deployment toolkit, then you require all of the .html, .jnlp and .jar files.
    3. If your application is launched via Webstart from a web page via a direct href link to the jnlp file, then you only need the .jnlp and .jar file.
    4. If your application is distributed as a "standalone program" (e.g. "Users launch it using a Java launcher, such as java -jar MyApp.jar, or by double-clicking the application JAR file."), then you only need the .jar file.
    5. If your application is distributed as a "self-contained" application then you need none of the .jnlp, .html or .jar files, as everything required to run your application will be packaged into a native install package (e.g. .rpm, .msi, .deb, .dmg) that you will distribute.

    Suggested Approach

    As you will be using the "standalone program" form of distribution, you only require the .jar file for distribution and can ignore other files created by the Java packaging tools.

    While you could have Idea package your application as a JAR by choosing Build | Build Artifacts | Edit... | + | JAR | From modules with dependencies..., I don't recommend that as you will also need to set a main class in the manifest and will lose some of the functionality of files which are packaged using Idea's "JavaFX Application" packaging type, such as in-built detection that the Java runtime used to launch the application meets minimum requirements to run JavaFX applications and transparent network proxy support.

    So instead, just use, unchanged, the Idea artifact packaging configuration that you have already setup. Ignore the .html files and .jnlp files output. Just distribute the .jar file to your users along with instructions on how to launch it either via java -jar MyApp.jar or double-clicking the .jar after a Java runtime has been installed on their machine.

    Portable Build Advice

    If it is only you developing the project and you are unfamiliar with external build tools such as maven or gradle, then it is (probably) simpler to use the artifact packaging features built into your Idea IDE rather than to learn and use external tools.

    If your project might potentially be worked on by other developers or builds are to be produced and tested within a continuous integration system such as Jenkins, I do not recommend relying on IDE specific build systems such as the artifact packager in Idea. Instead, use an external build tool such as maven or gradle. There is a maven plugin and a gradle plugin for JavaFX build.