You have developed a nice desktop application and have been breaking your head to create an executable to distribute for different platforms! Here comes Java Web Start for your rescue, distribute your Swing application via web, no installers, no custom code for desktop shortcuts, no tweaks for auto-upgrades! Let me explain the process step by step.
Step 1: Jar your classes and resources using your favorite build tool.
Say your jar file is myswingapp.jar, rename it to myswingapp__V1.0.jar, ie, add '__V' and an initial version say 1.0. I will explain why this is needed in the coming section.
Step 2: Organize your dependencies as below:
root _folder>myswingapp__V1.0.jar
root _folder>jarfile1.jar
root _folder>jarfile2.jar
root _folder>jarfile3.jar
Step 3: Create a jnlp file as below and save it as myswingapp.jnlp
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://mysite.com/downloads/"
href="myswingapp.jnlp">
<information>
<title>MySwingApp</title>
<vendor>MyOrg</vendor>
<description>A swing application</description>
<icon href='logo48.png' kind='default'/>
<icon kind="shortcut" href="icon.jpg" width="32" height="32"/>
<offline-allowed/>
<shortcut online="false">
<desktop/>
<menu submenu="MySwingApp"/>
</shortcut>
</information>
<security>
<all-permissions/>
</security>
<update check="background"/>
<resources>
<j2se version="1.6.0+"/>
<jar href="myswingapp.jar" main="true" version="1.0"/>
<jar href="jarfile1.jar"/>
<jar href="jarfile2.jar "/>
<jar href="jarfile3.jar "/>
<property name="jnlp.versionEnabled" value="true"/>
</resources>
<application-desc main-class="com.myorg.Main"/>
</jnlp>
Step 4: Copy all your jar files and the jnlp file to mysite.com/downloads/
Step 5: Create your download page say download.html and add the below script:
<script src="http://www.java.com/js/deployJava.js"></script>
<script type="text/javascript">
var url = "http://mysite.com/downloads/myswingapp.jnlp";
deployJava.createWebStartLaunchButton(url, '1.6.0');
</script>
Step 6: You are done! Now you can launch your application by accessing your download page, just click on the 'Launch' button, the installer will download your application and install it with a desktop shortcut as well as a menu item to launch the application. Great, isn't it?
Signing jars: If you want your application to run with full access, you must sign all your jar files.
Updates: An update check will be performed in the background and if an update is available, the application will download it and install it in the background! You just need to put your latest jar files, that's it!
ReplyDeleteAt My Home Improvement, the business partners get a golden opportunity where they can expand their business all across Australia. It is a local reference site where you can attract clients. At here on this free listing site the buyers can change the entire pattern of their business. It is one of the most visited websites by the clients to get businesses in Australia, which indicates you can reach and expand your business quickly. Read More :- My Home Improvement