views:

83

answers:

3

I am making a remastered distribution that was at first packed with Sun Java, however I decided I would like Java to run from a folder on the hard drive with my application instead. I see there's a portable Java for Windows - how can I do this with Linux? I haven't tried simply putting the whole folder in there but that seems like an ugly hack, and I'm not sure if there are other files in the Java install that need to be put in system directories.

A: 

You can simply copy the installation directory to your stick. Everything will work fine from there. This is true for windows as well as for linux.

tangens
+3  A: 

On Linux you download jre-6u21-linux-i586.bin from oracle site, you exec it, and you get all jre in one directory.

You can change this directory name, copy it an another Linux PC, tar it and untar it elsewhere, and so on. Then put the subdir bin on the PATH, that's all.

Istao
A: 

By portable, you mean java's definition. What you might mean though is installation. Java applications don't need to be installed. You should make a Jarfile with all the classes of your program. To do that, you can do this:

jar -cvf MyApplication.jar myapplicationfolder/

This will create jar file. You still need the manifest file, which you can edit with most normal archivers (7-zip, WinRAR, File-roller), etc. Open the jar file with any archiver, go to META-INF/MANIFEST.MF, and edit it. It should look like this:

Manifest Version //etc...
//two newlines, can't show them here.

Change it to

//...
Main-Class: pkg.to.mainclass.MainClassName
//two newlines.

Now you have an executable jar. This will run on any system with java installed.

Leo Izen