Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
402 views
in Technique[技术] by (71.8m points)

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

With the recent Java updates, many people are having trouble with their Java Web Start apps lacking Codebase, Permissions, and Application-name manifest attributes. Although there are resources out there to help you accomplish this, I couldn't find any comprehensive answers to this question, I so I felt a Q-and-A would be good. So, here's the question:

My Java Web Start app displays the following warnings in the console:

Missing Permissions manifest attribute for: http://www.codebase.com/myApp/dist/myApp.jar
Missing Codebase manifest attribute for: http://www.codebase.com/myApp/dist/myApp.jar
Missing Application-Name manifest attribute for: http://www.codebase.com/myApp/dist/myApp.jar

How do I fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

(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 distmyApp.jar addToManifest.txt

of course distmyApp.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 distlibjcommon-1.0.16.jar addToManifest.txt
jar ufm distlibjfreechart-1.0.13.jar addToManifest.txt
jar ufm distlibjoda-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 distmyApp.jar -keystore "C:myAppKEYSTORE.ks" alias -storepass password

You'll also need to do this for all of your libraries as well:

jarsigner distlibjcommon-1.0.16.jar -keystore "C:myAppKEYSTORE.ks" alias -storepass password
jarsigner distlibjfreechart-1.0.13.jar -keystore "C:myAppKEYSTORE.ks" alias -storepass password
jarsigner distlibjoda-time-2.2.jar -keystore "C:myAppKEYSTORE.ks" alias -storepass password

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

NOTE: You only need to sign/deploy your libraries once unless you are changing the library structure. i.e., if you are updating your app but the libraries have already had their manifests altered, signed properly, and deployed, you won't need to resign/deploy the libraries unless you are adding/removing libraries from your app.

NOTE #2: The current version of Netbeans will add Codebase and Permissions manifest attributes to your primary .jar only, but not to your libraries. If you use Netbeans, you will receive a warning from the jar utility when you try to add a duplicate manifest attribute. There is a bug report in the queue to have this fixed https://netbeans.org/bugzilla/show_bug.cgi?id=234231.

EDIT: The latest version of Netbeans (8.0) now adds all three (Codebase, Permissions, and Application-Name) to the manifest for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...