Java App installer and launcher for both Mac and Win? - java

I have a large Java app, with many required .jar files.
I'd like to build a native launcher and installer for it, to run it on both Mac and Win machines.
It looks like I can use Launch4J to create a .exe file launcher on Windows. (though it only wraps a single .jar, the others have to be available in the path.) Then use IzPack to create a runnable .jar file that will install the .exe and relevant .jar files into a directory.
How do I do the same for OS/X?

After more digging, and avoiding all the dead URL's I found, I've come up with:
A) Use Launch4J to build a .exe for Windows systems.
B) Use AppBundler (from java.com) to build a App Bundle for OS/X.
IzPack can be used to make an installer for either platform.

Related

Deploying Java application to a Linux computer

I have developed a desktop Java application on Windows using Eclipse. It is just a console application. It uses several third party jar files and on Windows, several third party dll files are also required.
On the Windows machine, I can run the app from a command prompt as well, which I have copied from Eclipse. The command prompt references several of the third party jar files in the -classpath argument. In the development environment on Windows, all the dll files have been placed in the project home directory. The third party jar files have been included in the project Properties, "Java Build Path" setting on Eclipse.
Now, I want to move and run this app to a Linux computer for deployment. How should I do it? One way would be to use the same command line that is being used on the windows machine with modified -classpath arguments with the destination of third party jar files on the Linux machine. Is that the right approach? On the linux machine, I would also need the third party Linux native .so files. Should I just copy them to the project directory on the Linux machine? Should the project directory structure be same as the one I have on my Windows development machine?
Or should I just export (Eclipse Export) everything into a jar file and run the app using java -jar myapp command? Where should I place the third party jar files and native .so files in that case?
I have read a lot on this topic but still cant get any clarity on whats the best approach especially with third party .dll, .so and jar files involved.

Java .JAR to desktop shortcuts/proper apps for windows, mac and debian

I have a multiplatform jar, that can run when clicked on all 3 platforms.
What would be the best way to install desktop shortcuts / apps, that would basically just symlink or link to that jar?
I think you require some sort of wizard installer. Which will take care of putting your jar to specific directory (program directory) and create desktop shortcut.
For windows OS you can use Jsmooth

Is there a tool which will package a copy of the JRE with my application so that it can run regardless of whether or not the user has Java installed?

This is my first brush with actually distributing a Java application. I'm coming from a Python background, which has a fantastic set of tools for distribution called PyInstaller, and Py2App. Both of these package up a copy of the Python Interpreter along with the application so that there's nothing to install for the end user. They simple see an .EXE or .app double click it, and the program starts.
So far, I have been unable to find a similar tool for Java. The idea behind this app is that it's stored on a flashdrive so it can be run without installing anything on the host machine.
I've found decent tools for Windows. For instance, Launch4J appears to do the trick, but it's for windows only. I'm desperately in need of similar functionality, but for making an app.
Has anyone faced this conundrum before? Are there any tools which I could use?
Have a look at install4j, it's a multi-platform Java installer (and launcher) builder. You can bundle a JRE with your installers.
Disclaimer: My company develops install4j
Lets assume you are distributing via a .zip file
You could drop a copy of the JRE in your app directory, then create a .bat and .sh script that will run the app with a java command using the JRE that is in the same directory.
There is probably a better tool to do this but this is one way it could be achieved.
A super simplified example .sh script
#!/bin/bash
jre/bin/java myapp.jar
Would run myapp.jar using the JRE in that location. In reality you would want to put checks to make sure the JRE exists.
the app folder:
myapp/
jre/
start.sh
start.bat
myapp.jar
the jre would be an actual JRE instance.

SWT jar for different platform

I am using JWebBrowser in a swing application. This class belongs to The DJ Project. It needs swt jar to execute. Now I have included swt jar for windows to my jar packaging of the application. I want to know how can I include swt jars for linux/mac in the same packaging? I am using ant to build the application jar. Should I build the jar putting different swt jar for different platform?
if you want to have a single build that runs on different platforms (Win/Mac/Linux/*nix) or architectures (32/64 bit) then you can bundle the SWT jar for each target platform with your installer and then load the correct one dynamically at runtime (or have your installer copy the correct SWT jar at installation time).
E.g. say you want to support 32 and 64 bit Windows and Linux you would have SWT jars:
lib/swt_win_32.jar
lib/swt_win_64.jar
lib/swt_linux_32.jar
lib/swt_linux_32.jar
Make your ant script / installer include all of these (they are about 1.6MB each) and then at runtime in your code you can detect the OS and architecture using the Java system properties
System.getProperty("os.name");
System.getProperty("os.arch");
to build the name of the correct jar file.
Loading the jar at runtime can be performed by a custom classloader or by calling the protected method URLClassloader.addURL(URL url) using reflection.
I've put working code to perform this exact task on my website: http://www.chrisnewland.com/select-correct-swt-jar-for-your-os-and-jvm-at-runtime-191
If you can stand the code-smell then it's a quick solution to a very common SWT problem.
On Mac OS +X, you can incorporate the required JAR and JNI libraries in an application bundle, as shown in this project. See also Deploying SWT Applications on Mac OS X.
On Linux, most platforms make an swt-gtk package available. As a concrete example, here's a startup script for AppleCommander:
java -Djava.library.path=/usr/lib/jni \
-cp /usr/lib/java/swt-gtk-3.5.1.jar:AppleCommander-1.3.5.8.jar \
com.webcodepro.applecommander.ui.AppleCommander -swt
This answer contains the code to select the correct SWT JAR when you start your application: Create cross platform Java SWT Application
All you need to do is put all the JARs in the correct folder and the code will pick them up.

How to convert jar files into exe & rpm

I have the following jar files for my app:
DesktopApplication1.jar
Plus , i have used the some extra API's for my app , like jsoup, jexcelapi etc. There are about 7 api's in the lib folder.
How to make a EXE file & RPM file out of all these jar files?
P.S. I am a first timer. So take that into consideration.also, I have used Netbeans 6.8. So the main API is in \dist folder. And the API used is in \dist\lib folder.
thanks in Advance
use jsmooth to make exe from jar
Build your JAR with fatJar to include all the dependencies in it, and then make it executable with your favorite tool (I use Launch4j)
RPM is little bit different, since it is not executable, but package format. There are lots of tutorials, how you build it up.
You could make a BAT file a file with .bat(For windows) extension
Just open notepad and write the following text
java -jar DesktopApplication1.jar
Save the file as filename.bat(the .bat extension is important)
Place the .jar and .bat files together and just double click the .bat file every time you need to run the jar...
If you don't want to keep both together then give the absolute path of the jar in the .bat file
java -jar AbsolutePath/DesktopApplication1.jar
For a linux machine make a file with (.sh) extension rest of the procedure is same...
Try InstallJammer. It provides what you want.
Deploy the app. with Java Web Start. JWS Can make it easy to add other Jars to the apps. run-time class-path, avoiding the common problem with fat jar of violating the API's distribution license (when it says WTE 'you are allowed to distribute this in unaltered form..') and can provide the further benefit of only downloading the parts that the user requires (when the user requires them).
JWS has many other cool features like desktop integration (menu bars, start menu item), splash screens, automatic updates, support by the owners of Java, and compatibility with any platform for which Java is available.
For creating .exe to run on Windows:
Download launch4j from http://launch4j.sourceforge.net.
build wrapper .exe through launch4j.
Download innoSetup from http://www.jrsoftware.org/isdl.php.
Build .exe as installer, the setup file, for user to download and install.
Install rpm for linux:
If your application used other native libraries, you need to download and install Linux native libraries. This is how we build rpm for our app.

Categories

Resources