I've been trying to convert a jar to exe. The program - the jar - uses a bluetooth library 'Bluecove' which is another jar in some directory. The program also uses Java Swing, typically JFrame
and stuff. The program works perfectly when run from within Netbeans or Eclipse. It's time for me to deploy it, hence I need to convert it to exe. But I've been unable get the final executable to link with 'Bluecove'. I tried JSmooth and Launch4j , but with both, though I could complete the process and create the 'exe', the final program isn't running, because it can't find the Bluecove classes.
Any suggestions on how to get around this? None of these converters have any documentation about linking with libraries. Any help is appreciated.
Solution: Thanks guys for the answers! I used Andrew Thompson's suggested method to deploy my program, which worked beautifully. And to create the JAR, I preferred to have everything in one JAR, as suggested by Abdullah Shaikh. I used Fat-Jar Eclipse plugin for that.
Make sure you added bluecove JAR into classpath when creating launcher: setting classpath in JSmooth, setting classpath in Launch4j.
Those two statements do not make sense together. We cannot deploy a Swing desktop app. to *nix or OS X using a Windows based executable. The best option for deploying a Java desktop app. is typically from a link on a web page using Java Web Start.
From BlueCove Documentation: Installation:
This would imply something like the following. 2 Java Web Start based JNLP extensions:
bluecove.jar
) to support Windows and OS X, as well as the core classes needed for Linux. This 'main' JNLP file would have a resources section specific to Linux, which in turn references the 'Linux only' extension JNLP.bluecove-gpl.jar
) which includes an installer element to pop a license prompt for the user (if needed, this entire extension is necessary only for producing a license prompt). Here is a small demo. of theExtensionInstallerService
that would show a license agreement.The Java Web Start client (the app. that launches an appropriate JVM and your app.) would typically check back with the home server for updates to the application Jars relevant to that OS. Fortunately it is configurable as to when and how the check is done, and whether the application can be run 'off-line' as you require, by specifying an element in the JNLP:
The
offline-allowed
element (part of thejnlp
element) ensures that after initial installation, the app. can be used off-line.To resolve this issue you put all dependent jars inside your final jar file.
In eclipse, you can do this in following way:
File -> Export -> Java -> Runnable Jar File -> (Select the option) Package required libraries into generated jar
Now use this jar to create an exe using any jar to exe converter of your choice!
hope this helps
Inside the jar you need to put all dependant jars or you can have manifest for your jar use the Class-Path header.
You can also try fat-jar extension or One Jar