问题描述
在Windows中, JAVA_HOME
必须指向JDK安装文件夹(以便 JAVA_HOME / bin
包含所有可执行文件和 JAVA_HOME / libs
包含所有默认的 jar
库)。
如果我下载Sun的JDK软件包并将其安装到Linux中,则它是相同的过程。
但是,我需要使用Kubuntu的默认OpenJDK软件包。问题是所有的可执行文件都放在 / usr / bin
中。但是这些jar放在 / usr / share / java
中。由于它们不在同一个 JAVA_HOME
文件夹中,因此我遇到了Grails问题,并且可能会遇到期望标准Java结构的其他应用程序出现问题。
-
如果我使用:
JAVA_HOME = / usr
想要使用任何Java可执行文件的所有应用程序和脚本都可以使用标准过程
调用$ JAVA_HOME / bin / executable
。然而,由于罐子在不同的地方,它们并不总是被找到(例如:在grails中,对于native2ascii $,我得到
ClassDefNotFound
另一方面,如果我使用:
>
JAVA_HOME = / usr / share / java
没有Java可执行文件(可以找到 java
, javac
等)。
那么,在基于Debian的Linux中处理 JAVA_HOME
变量的正确方法是什么?
感谢您的帮助,
Luis
我(Grails现在可以正常工作)几乎像Steve B.指出的那样:
$ p $ JAVA_HOME = / usr / lib / jvm / default-java
这样,如果用户更改了系统的默认JDK, JAVA_HOME
仍然有效。
default-java
是curre的符号链接nt JVM。
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).
If I download Sun's JDK bundle and installs it in Linux, it is the same procedure.
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.
If I use:
JAVA_HOME=/usr
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 gettingClassDefNotFound
fornative2ascii
).On the other hand, if I use:
JAVA_HOME=/usr/share/java
None of the Java executables (
java
,javac
, etc.) can be found.
So, what is the correct way of handling the JAVA_HOME
variable in a Debian-based Linux?
Thanks for your help,Luis
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
This way if the user changes the default JDK for the system, JAVA_HOME
still works.
default-java
is a symlink to the current JVM.
这篇关于Linux OpenJDK基于Debian的发行版的JAVA_HOME环境变量的正确目标是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!