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:
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.
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 |
<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 |
<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.
Hi, colleague! I like your blog, it’s so interesting! I think it’s pretty popular, isn’t it? I would like to invite you to my favorite Pay-Per-Click system, I believe you can earn with your blog a lot here. My crazy russian friend earns $3.000 per day here! Look, it doesn’t obligate you to anything http://klikvip.com/landings/en/landing2/index.php?aff=35357
Pingback: Java
it’s all about java..
This was really informative! I thanks for the info! I’m not a newbie and even I learned some great things from this one. One thing though… I can’t seem to get your RSS feed link to work. Can you help me with that?
This actually answered my problem, thanks!
But this option isn’t available in NtBeans 7.1.2.What to do? Please tell me…
@deepak which option?
i couldnt able to do using netbeans 7.0.1
plss help me with steps
The steps are same . There wont’ be any vast change I guess. Right Click Project>Properties>Application>WebStart> Check “Enable Web Start” then select appropriate class and click on Ok! Finally Click on Clean and Build Icon(Shift+F11).
Thanks
Narayan