Linux 上的可移植 JRE - 可能吗?

发布于 2024-09-25 00:35:13 字数 193 浏览 0 评论 0原文

我正在制作一个重新制作的发行版,最初是用 Sun Java 打包的,但是我决定让 Java 与我的应用程序一起从硬盘驱动器上的文件夹中运行。我看到有一个适用于 Windows 的可移植 Java - 我如何在 Linux 上执行此操作?我还没有尝试简单地将整个文件夹放在那里,但这看起来像是一个丑陋的黑客,而且我不确定 Java 安装中是否还有其他文件需要放入系统目录中。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼眸印温柔 2024-10-02 00:35:13

在 Linux 上,您从 oracle 站点下载 jre-6u21-linux-i586.bin,执行它,然后将所有 jre 放在一个目录中。

您可以更改此目录名称,将其复制到另一台 Linux PC,将其压缩并解压缩到其他位置,等等。然后将子目录 bin 放在 PATH 上,仅此而已。

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.

谁的新欢旧爱 2024-10-02 00:35:13

您只需将安装目录复制到您的棒上即可。从那里一切都会顺利进行。对于 Windows 和 Linux 都是如此。

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.

不念旧人 2024-10-02 00:35:13

只需下载 tar.gz,将其解压到一个文件夹,然后将 usr/java/jreX.X.X_XX 移动到您想要的文件夹

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

枉心 2024-10-02 00:35:13

你所说的可移植是指java的定义。但你的意思可能是安装。不需要安装 Java 应用程序。您应该制作一个包含程序所有类的 Jarfile。为此,您可以这样做:

jar -cvf MyApplication.jar myapplicationfolder/

这将创建 jar 文件。您仍然需要清单文件,您可以使用大多数普通归档程序(7-zip、WinRAR、File-roller)等对其进行编辑。使用任何归档程序打开 jar 文件,转到 META-INF/MANIFEST.MF,然后编辑它。它应该看起来像这样:

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

将其更改为

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

现在您有了一个可执行的 jar。这将在任何安装了 java 的系统上运行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文