After beating my skull and the contents in it as a result of something hardly recognizable as a consistent thought, I managed to compose a script that will complete the task that I decided to complete. Most of this is taken from contributions from other nations and from consultation docs . Another important contribution can be found here (Last comment on the topic, it refers to another SO answer, but this SO answer did not help me). Thanks to everyone from which I was able to extract part of the solution. I hope that it will be useful for anyone who wants / wants to complete this task.
In any case: first, first: Properties:
<property name = "JFXProject.name" value = "PROJECT"/> <property name = "JFXMainClass" value = "MAINPACKAGE.MAINCLASS"/> <property name = "JFX.src.dir" value = "src"/> <property name = "JFX.lib.dir" value = "dist/lib"/> <property name = "JFX.build.dir" value = "release/JFXBuild"/> <property name = "JFX.sign.dir" value = "release/JFXSign"/> <property name = "store.dir" value = "release/store"/> <property name = "sign.dir" value = "release/sign"/> <property name = "comodo.key.store" value = "PATH-TO-YOUR-CERTIFICATE" /> <property name = "comodo.key.storepass" value = "PASSWORD"/> <property name = "comodo.key.alias" value = "ALIAS"/> <property name = "comodo.key.pass" value = "PASSWORD"/> <property name = "timestamp.url" value = "TIMESTAMPURL"/>
You can change the property names to something more meaningful if you want, but make sure they are consistent throughout the script.
Next, we want to clear the latest assembly:
<target name = "JFXClean"> <echo>Cleaning ${JFX.build.dir}...</echo> <delete dir = "${JFX.build.dir}"/> <delete dir = "${JFX.sign.dir}"/> <delete dir = "${store.dir}"/> <delete dir = "${sign.dir}"/> </target>
Then we want to recreate the directories for the new clean build ...
<target name = "JFXInit" depends = "JFXClean"> <echo>Creating the build directory...</echo> <mkdir dir = "${JFX.build.dir}"/> <mkdir dir = "${JFX.sign.dir}"/> <mkdir dir = "${store.dir}"/> <mkdir dir = "${sign.dir}"/> </target>
This part is critical to getting a working JavaFX JAR file:
<target name = "JFXBuild" depends = "jar, JFXInit"> <fx:jar destfile = "${JFX.build.dir}/${JFXProject.name}.jar"> <fx:application name = "${JFXProject.name}" mainClass = "${JFXMainClass}"/> <fileset dir = "build/classes"/> </fx:jar> </target>
This will correctly store all parts in their locations in the JAR (including any CSS and JFXML file that you may have. If you do not create a JFXML application, this may be optional. I do not know that I have not tested it.
Then we want to sign the JavaFX JAR:
<target name = "JFXSign" depends = "JFXBuild"> <fx:signjar keystore = "${comodo.key.store}" alias = "${comodo.key.alias}" storetype = "PKCS12" <!-- This is necessary for me, but may not be for you if you are not using a PFX file --> keypass = "${comodo.key.pass}" storepass = "${comodo.key.storepass}" jar = "${JFX.build.dir}/${JFXProject.name}.jar" destdir = "${JFX.sign.dir}"/> </target>
After that, there are two more goals that handle the zip search and then set this zip, and one finale for singing the last can:
<target name = "build" depends = "JFXSign"> <jar destfile = "${store.dir}/temp_final.jar" filesetmanifest = "skip"> <zipgroupfileset dir = "${JFX.build.dir}" includes = "*.jar"/> <zipgroupfileset dir = "${JFX.lib.dir}" includes = "*.jar"/> <manifest> <attribute name = "Main-Class" value = "${JFXMainClass}"/> </manifest> </jar> </target> <target name = "store" depends = "build"> <zip destfile = "${store.dir}/${JFXProject.name}.jar"> <zipfileset src = "${store.dir}/temp_final.jar" excludes = "META-INF/*sf, META-INF/*.DSA, META-INF/*RSA"/> </zip> <delete file = "${store.dir}/temp_final.jar"/> </target> <target name = "BuildStoreAndSign" depends = "store"> <signjar keystore = "${comodo.key.store}" alias = "${comodo.key.alias}" storetype = "PKCS12" <!-- This is necessary for me, but may not be for you if you are not using a PFX file --> tsaurl = "${timestamp.url}" keypass = "${comodo.key.pass}" storepass = "${comodo.key.storepass}" jar = "${store.dir}/${JFXProject.name}.jar" destdir = "${sign.dir}"/> <delete dir = "${JFX.compile.dir}"/> <delete dir = "${JFX.build.dir}"/> <delete dir = "${JFX.sign.dir}"/> <delete dir = "${store.dir}"/> </target>
I can not explain this very much, because I do not know an expert on this issue. I was able to basically extract the meaning of what I was looking for from the sample code and sources that I found and compile them to get the following: One last bit of information that was midfielded was this , but please note that this DOES NOT use one jar (I tried it with one jar but it didn’t work, it didn’t inject CSS and didn’t use it).
Also a little warning: This worked for me . I can’t guarantee that this will be for you, but I think that messing with it will produce results similar to mine (one JavaFX JAR application that works where you put it).