Ok now i’m here to show some good feature of Java . Java has a seperate extension like as to the C/C++. Many C/C++ uses .exe(executables) for executing the program in a bundle form . In the same way previously Java uses JAR file as executable but later from Java 2 SE 1.5 the new extension (*.jnlp) had took place for executing the java programs.

Here we are going to create a .jnlp file via NetBeans 6 Ok first create one simple Project which display some GUI. Or you can download sample NetBeans Project from here

Let’s take step by step process:

Press Ctrl+1 and you will see Project tab at your left Pane(for more.. )

Right click on Project Properties then you can see a dialog boxlike as in picture given below:

 

Project Properties

Now you can see there Tree menu ‘Application’ just click on that node and now you can specify your Application Brief:

  • Title
  • Vendor
  • Description
  • Home Page
  • Splash Screen

Title:Here you can specify the title of your program which can be visible at the installation of jnlp file.

Vendor:This vendor is the name of the company you can type which is also visible at installation of jnlp file.

Description : It’s just to give detail info of about the program

Home Page: For the link to your own home page via program installation you can put link here.

Splash Screen: Before opening your program you can show some splash screen like loading image or org image.

After all you can head toward the sub root the Application i.e. ‘Web Start’ now just make click on check box(checked)

‘Enable Web Start’ then now there you will see some stuff like this:

  • Allow Offline
  • Self-signed
  • Application descriptor(Use Project Main Class)
  • Applet descriptor

Allow Offline: This option is to run your program on offline

Self-Signed: This option will just sign your jnlp and jar file from the netbeans with default of 6 month duration

Application descriptor: This option will search the Main.class file in your jar file and run the program while executing jnlp file.

Applet Descriptor: Here you can run your program also in browser by specifying which class to be run (for eg. sample.WebGUI)

After all click ok then . Press F6 then it will start to compile and compress your class files at jar file and run via jnlp.

Then you must be gettting dialog box like this.

JNLP Dialog Box

Just click on Run as it’s only the security warning because our program is not trusted by the Sun java Security. Now your program will run with JNLP file and there you can see your output of your program .

Actually your jnlp file are being created at folder /dist of your project directory. Now if you see you jnlp file codes then your codes some how looks like this.

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/Users/JavaNep/Desktop/Sample/dist" href="launch.jnlp" spec="1.0+">
    <information>
        <title>Sample</title>
        <vendor>javacoder</vendor>
        <homepage href="http://javacoder.co.cc"/>
        <description>Sample</description>
        <description kind="short">Sample</description>

        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <j2se version="1.5+"/>
        <jar eager="true" href="Sample.jar" main="true"/>
    </resources>
    <application-desc main-class="sample.Main">
    </application-desc>
</jnlp>

Code:

1.
<jnlp codebase="file:/C:/Users/JavaNep/Desktop/Sample/dist" href="launch.jnlp" spec="1.0+">

codebase attributes defines about the path(directory) of your jnlp file and jar files and then launch.jnlp defines the jnlp file to be executed. with specification of 1.0+

Code:

1.
2.
3.
4.
5.
6.
7.
8.
9.
<information>
        <title>Sample</title>
        <vendor>Razer</vendor>
        <homepage href=""/>
        <description>Sample</description>
        <description kind="short">Sample</description>

    <offline-allowed/>
</information>

Here you can see the Information of this jnlp file which defines all the attributes which was defined at NetBeans like title,homepage,description,offline allowed as well.

Code:

1.
2.
3.
4.
<security>
<all-permissions/>
</security>

Now this is for the security of the jnlp file where there is declaration of all permission to the jnlp file .

Code:

1.
2.
3.
4.
<resources>
       <j2se version="1.5+"/>
       <jar eager="true" href="Sample.jar" main="true"/>
</resources>

Resources means the supporter file which is needed to run the jnlp file. Likewise here we have supporting file called Sample.jar.

Code:

1.
2.
3.
<application-desc main-class="sample.Main">
</application-desc>

As we had already mentioned that our program to run on Application Descriptor instead of Applet and Component Descriptor. So here our xml presents application Descriptor to run the file Main.class which is located at the package named sample which package is taken from the supporting file named sample.jar.

If any error are just evolved then comment at the blog you are welcomed.