Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

Tags:

java

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?

like image 295
Zack Avatar asked Feb 21 '13 17:02

Zack


2 Answers

Have a look at install4j, it's a multi-platform Java installer (and launcher) builder. You can bundle a JRE with your installers.

enter image description here

Disclaimer: My company develops install4j

like image 190
Ingo Kegel Avatar answered Oct 09 '22 05:10

Ingo Kegel


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.

like image 43
cowls Avatar answered Oct 09 '22 05:10

cowls