Wednesday, April 2, 2008

jnlp and web start

Wow!! finally after all the hard time i am able to get JNLP and web start running for my application. There are no editors available for jnlp to create, check for errors or verify it. We can create a JNLP file in netbeans but validation is not provided, which is the major drawback. And the other way is to create it using a text editor itself. JNLP stands for Java Network Launching Protocol. It is a protocol that specifies how applications are launched using web start. JNLP need a web server to launch the application. Some times the most common problem that is faced with the JNLP is that it displays the plain JNLP file with out launching the application. This is because the mime-type for the JNLP file is not added into the web servers mime types. to have it working we can have this added into the mime-types of the server. application/x-java-jnlp-file jnlp
Now lets see the outline of a simple jnlp and the way it is used to load application that can be easily accessed off the web using a java web start. As the jnlp is an xml file we do have the xml tag defined in the very beginning.
  • jnlp tag is used to specify that this is a jnlp file along with the version. The default version is 1.0.
  • codebase within the jnlp tag contains information about the base url that forms a basis for all the hrefs used in the file. So base url forms the base directory for all the files.
  • The href within the tag contains a reference to the jnlp file.
The information section which contains information about the application.
  • First tag is the title tag which contains the name of the application
  • Vendor tag contains the information about the vendor for the application.
  • homepage refers to a home page that is related to the application or has information about the application.
  • The description field is used for a brief description about the application.
Resource section is one of the most important sections in the jnlp.
  • Starts with the version of java the application can start running fine.
  • The next jar specification tells us about the application jar that contains the main class and is used to load and run the application. This also contains a main attributes, specifying that to true helps web start to identify that this jar contains the main class.
  • All the subsequent jar contains information about the libraries that needs to be included.
Please note that all the references here are in reference to the url at the code base. The final statement here is the one that specifies the main class that is used to start the application. This main class should be present in the jar that is specified as main = true in the jars. Another most important point to be noted is that the application is run only when all the jars are signed using an RSA signature. so before creating a JNLP file first we need to sign the application jars using the same signature. If using external libraries and it contains its own signature then a new jnlp file is created for that library and have this jnlp embedded into the application jnlp

1 comment:

SBTVD said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the SBTVD, I hope you enjoy. The address is http://sbtvd.blogspot.com. A hug.