Portable JRE on Linux - possible?

隐身守侯 提交于 2020-01-14 22:45:30

问题


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.


回答1:


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.




回答2:


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.




回答3:


Just download the tar.gz, extract it to a folder and move the usr/java/jreX.X.X_XX to a folder you wish




回答4:


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.



来源:https://stackoverflow.com/questions/3764168/portable-jre-on-linux-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!