Introduction and use of JNLP
1. What is JNLP? Java provides a way for you to directly execute Java applications through a browser, which enables you to directly open a Java application program through a URL Connection on a web page. the benefit is worth noting. If your Java application is released in the form of JNLP, if you do not need to release a version to all users after the version upgrade, you only need to update the server version, this is equivalent to giving Java applications the advantages of Web applications.
2. Create a web application, write a test class test. Java, compress the test class into a jar package, name it jnpl. jar, and put it under the root directory of the Project webroot.
3. Create a New JNLP suffix named testjnpl. JNLP and put it under the root directory of the project,
The configuration code is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- The address here is the JNLP access path -->
<JNLP codebase = "http: // 10.11.0.138: 8080/jnpltest/" name = "seatingchartbuilder"
Href = "testjnpl. JNLP">
<Information>
<Title> seating chart builder </title>
<Vendor> etix.com, Inc. </vendor>
<Offline-allowed/>
<Description> An application to seating chart builder! </Description>
</Information>
<Application-Desc main-class = "com. Test"/>
<Security>
<All-permissions/>
</Security>
<Resources>
<J2se version = "1.4 +"/>
<Jar href = "jnpl. Jar"/>
</Resources>
</JNLP>
4. Sign the generated JNLP. JAR File
(1) first generate a certificate. The command is as follows. This command will generate a file named myjnlp. keystore in the current directory.
Keytool-genkey-alias myjnlp-validity 123456-keypass 123456-storepass 123456-keystore myjnlp. keystore-dname "cn = nokiaguy, ou = nokiaguy, O = D, L = Ca, S = Ca, c = cn"
(2) convert the generated myjnlp. the keystore is placed under the root directory of the project, and the jnpl. jar to sign and put the signed JAR file under the project root directory. Here, myjnlp is the alias myjnlp when the certificate is generated.
Jarsigner-keystore myjnlp. keystore-storepass 123456-keypass 123456 jnpl. Jar myjnlp
5. Access http: // 10.11.0.138: 8080/jnpltest/testjnpl. JNLP to run the JNLP file!
Conclusion: The Running method is similar to Java-jar jarname. jar.
Note that for multiple jar packages, you need to sign each jar package and the signature must be the same. If multiple jar packages have different signatures, the error "inconsistent jar resource signature certificates in the JNLP file" is reported.
Sometimes Call the jar package signed by someone else, even if you re-sign, the above error will be reported, because there are two signature files in the jar package's META-INF folder, delete the previous signature file.