Skip to content
October 15, 2009 / Narayan

JNLP on Desktop and Start Menu with Icon

As you have already heard about the extension (*.jnlp) which had made the java developer more easier to present their programs with a single file..

Actually the jnlp extension is a ext. of Sun Java. We can simply present the jnlp in both web(browser) and desktop .

The Web Start mechanism has made this jnlp to run at the top of Java 2 platform.

In this blog I’m going to show how can we make our program to display as a icon at Desktop and Start Menu.

As i’m just going through a sample jnlp file which is being resulted by NetBeans..see (how  to create jnlp from NetBeans).

Ok here is our JNLP code:

<?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>

(more details about jnlp….)
You can see it’s very simple one jnlp file, where there is only one jar file named Sample.jar and the main class file is Main.class which is represented at sample package (sample.Main).

For the icon at Desktop and Start Menu:-
Now our modified code goes here :

For Icon:

<icon href="logo.png" kind="default"/>

You can place your own icon image by specifying exact path of the icon in replace of logo.png  and if  your icon is in the dist folder then you can simply place the name of the file and extension like as in above example.

For Shortcut at Desktop and StartMenu:

<shortcut online="false">
	<desktop/>
	<menu submenu="Sample">
	<menu submenu="Sample Sub menu"/>
	</menu>
</shortcut>

Also If you want to keep splash screen then use this:

<icon href="load.png" kind="splash"/>

After all our complete modified jnlp file will be like as below code:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/Users/Razer/Desktop/Sample/dist" href="launch.jnlp" spec="1.0+">
    <information>
        <title>Sample</title>
        <vendor>Razer</vendor>
        <homepage href=""/>
        <description>Sample</description>
        <description kind="short">Sample</description>

	<icon href="load.png" kind="splash"/>

	<icon href="logo.png" kind="default"/>

	<shortcut online="false">
		<desktop/>
			<menu submenu="Prabinas">
			<menu submenu="Product Managing System"/>
			</menu>
	</shortcut>
<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>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: