Tuesday, June 10, 2014

How do I fix “missing Codebase, Permissions, and Application-Name manifest attribute” in my JNLP app?

(1) First, you need to create a text file with all of the attributes you want to add. My text file looks like this:
Permissions: all-permissions
Codebase: http://www.codebase.com/myApp/dist
Application-Name: My Application
I named it addToManifest.txt. Obviously, you'll need to change the parameters to match your application's needs.

(2) Next, you need to add this to the main .jar and all of the libraries as well. The command to do this is:
jar ufm dist\myApp.jar addToManifest.txt
of course dist\myApp.jar will need to point to whatever your main .jar is. You'll also need to do this for all of the libraries as well.
jar ufm dist\lib\jcommon-1.0.16.jar addToManifest.txt
jar ufm dist\lib\jfreechart-1.0.13.jar addToManifest.txt
jar ufm dist\lib\joda-time-2.2.jar addToManifest.txt
...
(Note: on Windows, I wrote a .bat file for this.)
Once you do this, the attributes should be written to the .jars. You can open the .jars in a zip manager (like 7-Zip), extract the MANIFEST.MF file, open it in a text editor, and you should see the attributes listed.

(3) After adding the attributes, you need to resign your app. The command to do that is:
jarsigner dist\myApp.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password

You'll also need to do this for all of your libraries as well:
jarsigner dist\lib\jcommon-1.0.16.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password
jarsigner dist\lib\jfreechart-1.0.13.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password
jarsigner dist\lib\joda-time-2.2.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password

After that, your attributes should be added and your .jars should be signed!

No comments:

Post a Comment