基于Linux OpenJDK Debian的发行版的JAVA_HOME环境变量的正确目标是什么? [英] What is the correct target for the JAVA_HOME environment variable for a Linux OpenJDK Debian-based distribution?

查看:216
本文介绍了基于Linux OpenJDK Debian的发行版的JAVA_HOME环境变量的正确目标是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中, JAVA_HOME 必须指向JDK安装文件夹(以便 JAVA_HOME / bin 包含所有可执行文件,并且 JAVA_HOME / libs 包含所有默认的 jar 库)。

In Windows, JAVA_HOME must point to the JDK installation folder (so that JAVA_HOME/bin contains all executables and JAVA_HOME/libs contains all default jar libraries).

如果我下载Sun的JDK软件包并将其安装在Linux中,则是相同的过程。

If I download Sun's JDK bundle and installs it in Linux, it is the same procedure.

但是,我需要使用Kubuntu的默认OpenJDK软件包。问题是所有可执行文件都放在 / usr / bin 中。但是罐子放在 / usr / share / java 中。由于它们不在同一个 JAVA_HOME 文件夹下,所以我遇到了Grails的麻烦,也许其他使用标准Java结构的应用程序也会遇到麻烦。

However, I need to use Kubuntu's default OpenJDK package. The problem is that all executables are placed in /usr/bin. But the jars are placed in /usr/share/java. Since they are not under the same JAVA_HOME folder I'm having trouble with Grails and maybe there will be trouble with other applications that expect the standard Java structure.


  1. 如果我使用:

  1. If I use:

JAVA_HOME=/usr

所有要使用任何Java可执行文件的应用程序和脚本都可以使用标准过程调用$ JAVA_HOME / bin / executable 。但是,由于罐子位于不同的位置,因此并不总是可以找到它们(例如:在grails中,我得到 native2ascii ClassDefNotFound c $ c>)。

All applications and scripts that want to use any Java executable can use the standard procedure call $JAVA_HOME/bin/executable. However, since the jars are in a different place, they are not always found (example: in grails I'm getting ClassDefNotFound for native2ascii).

另一方面,如果我使用:

On the other hand, if I use:

JAVA_HOME=/usr/share/java

没有Java可执行文件( java javac 等)。

None of the Java executables (java, javac, etc.) can be found.

那么,在基于Debian的Linux中处理 JAVA_HOME 变量的正确方法是什么?

So, what is the correct way of handling the JAVA_HOME variable in a Debian-based Linux?

感谢您的帮助,
Luis

Thanks for your help, Luis

推荐答案

最终成功的方法我(Grails现在可以正常工作)的运行几乎就像Steve B.指出的那样:

What finally worked for me (Grails now works smoothly) is doing almost like Steve B. has pointed out:

JAVA_HOME=/usr/lib/jvm/default-java

这样,如果用户更改了系统的默认JDK,则 JAVA_HOME 仍然有效。

This way if the user changes the default JDK for the system, JAVA_HOME still works.

default-java 是当前链接的符号链接JVM。

default-java is a symlink to the current JVM.

这篇关于基于Linux OpenJDK Debian的发行版的JAVA_HOME环境变量的正确目标是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆