How can I sign and deploy a JavaFX application in a single .JAR?

I am still exploring all the features of JavaFX. One of the main differences is that in the dist folder (in addition to the library), I find in addition to the .jar file, an HTML file and a JNLP file, none of which are used for me (this will be a desktop application).

I found the following (Properties omitted due to sensitive / irrelevant information):

<delete dir="${store.dir}"/> <mkdir dir="${store.dir}"/> <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip"> <zipgroupfileset dir="dist" includes="*.jar"/> <zipgroupfileset dir="dist/lib" includes="*.jar"/> <manifest> <attribute name="Main-Class" value="${main.class}"/> </manifest> </jar> <zip destfile="${store.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"/> <delete dir = "${build.output.dir}"/> <mkdir dir = "${build.output.dir}"/> <signjar jar = "${store.jar}" signedjar = "${build.output.dir}/${FileName}" alias = "${comodo.key.alias}" storepass = "${comodo.key.storepass}" keystore = "${comodo.key.store}" storetype = "PKCS12" keypass = "${comodo.key.pass}" tsaurl = "${timestamp.url}"/> 

This was intended to create both an “executable” MAIN JAR and all dependent libraries in a single .JAR that can be run from anywhere, then take and sign this JAR and transfer it to a “signed” directory.

This works great for any JAR library or Swing GUI JAR application, but when I tried the same with a JavaFX application, it worked:

 Error: Could not find or load main class com.javafx.main.Main 

I'm not quite surprised to see that it does NOT work, but this is a bit of a problem. I did some research on the feasibility of deploying a "stand-alone" application, but this does not suit our needs. My employer bought a Comodo certificate for some reason, and I quickly ran into a wall that seems to be due to Apple shenanigans (if I'm not mistaken in this presumption), you should join their development club for a low cost in $ 100 per year (not happening). I really don't do development for the Apple SPECIFICALLY platform. I am developing Java. In any case, if I'm right, this will not work for us, so there is no offline deployment for Windows, Linux, and Mac (again, if I'm right).

I hope this is something simple.

So, how do I apply the generated ANT script created to compile the JAR containing all the dependent LIBs into a code-formatted JAR in a JavaFX application?

EDIT 1: Okay, so definitely spoke too soon. Not very close to the answer. I tried to explain to frankenstein that I know about compiling and signing regular JAR files so that all libraries are included and that the sign is successful in that I was able to choose from the manual . I have a mess and a failure. I get a .JAR file with everything in it except the main .JAR file. In any case, this is the ANT script code:

Properties:

 <property name = "name" value = "APPNAME"/> <property name = "file" value = "APPJAR"/> <property name = "MC" value = "MAINPACKAGE.MAINCLASS" /> <property name = "released.dir" value = "released"/> <property name = "compiled.dir" value = "${released.dir}/compiled"/> <property name = "stored.dir" value = "${released.dir}/stored"/> <property name = "signed.dir" value = "${released.dir}/signed"/> 

All the rest:

 <delete dir = "${released.dir}"/> <mkdir dir = "${compiled.dir}"/> <fx:jar destfile = "dist/compiled.jar"> <fx:platform javafx = "8.0+" j2se = "8.0"/> <fx:application name = "${name}" mainClass = "${MC}"/> <fileset dir = "build/classes"/> <fx:resources> <fx:fileset dir = "dist" includes = "lib/*.jar"/> </fx:resources> </fx:jar> <fx:signjar keystore = "${comodo.key.store}" alias = "${comodo.key.alias}" storetype = "PKCS12" keypass = "${comodo.key.pass}" storepass = "${comodo.key.storepass}" jar = "dist/compiled.jar" destdir = "${compiled.dir}"/> <mkdir dir = "${stored.dir}"/> <jar destFile = "${stored.dir}/temp_final.jar" filesetmanifest = "skip" > <zipgroupfileset dir = "${compiled.dir}" includes = "compiled.jar"/> <zipgroupfileset dir = "dist/lib" includes = "*.jar"/> <manifest> <attribute name = "Main-Class" value = "${main.class}"/> </manifest> </jar> <zip destfile = "${stored.dir}/${file}"> <zipfileset src = "${stored.dir}/temp_final.jar" excludes = "META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/> </zip> <delete file="${stored.dir}/temp_final.jar"/> <mkdir dir = "${signed.dir}"/> <signjar keystore = "${comodo.key.store}" alias = "${comodo.key.alias}" storetype = "PKCS12" tsaurl = "${timestamp.url}" keypass = "${comodo.key.pass}" storepass = "${comodo.key.storepass}" jar = "${stored.dir}/${file}" destdir = "${signed.dir}"/> 

And this is what I have to show for my time. If someone can learn something from this that can put me on the right track (if I’m even close, that I don’t feel like me), that would be super amazing.

+2
source share
2 answers

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"/> <!-- Put your own project name here --> <property name = "JFXMainClass" value = "MAINPACKAGE.MAINCLASS"/> <!--Put your own main class here --> <!-- don't edit below this line --> <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" /> <!-- You can name this what you like, but you want to make sure the value points to your certificate or JKS file --> <property name = "comodo.key.storepass" value = "PASSWORD"/> <!-- Above applies here. Make sure it the right password --> <property name = "comodo.key.alias" value = "ALIAS"/> <!-- Make sure it your right alias. You can find out how to find that information from [here][3] --> <property name = "comodo.key.pass" value = "PASSWORD"/> <!-- In my own experience this was the same as the storepass but it may be different for you --> <property name = "timestamp.url" value = "TIMESTAMPURL"/> <!-- This will vary for you depending on your certificate. --> 

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

0
source

Oracle says: http://www.oracle.com/technetwork/articles/javase/single-jar-141905.html

Need to change

 <manifest> <attribute name="Main-Class" value="${main.class}"/> </manifest> 

and change it to

 <manifest> CHANGE application.MainClass to <attribute name="JavaFX-Application-Class" value="application.MainClass" /> <attribute name="Main-Class" value="com/javafx/main/Main" /> </manifest> 

But listening to Oracle above led me to get one JavaFX with external banks in one.

0
source

All Articles