走向“真实” JAVA_HOME的定义 [英] Towards the "true" definition of JAVA_HOME

查看:104
本文介绍了走向“真实” JAVA_HOME的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个在* NIX系统(OS X,Ubuntu,...)之间切换的Java开发人员,虽然我总能启动我的JDK并且正在运行,但似乎在许多软件包中没有明确的JAVA_HOME定义这需要设置JAVA_HOME:

As a Java developer who switches between *NIX systems (OS X, Ubuntu, ...), although I can always "get" my JDK up and running, it seems that there is no clear definition of JAVA_HOME in many packages which require JAVA_HOME to be set :

例如


  • MAVEN:JAVA_HOME,指向您的JDK目录

  • HADOOP:JAVA_HOME,指定Java 1.5.x安装的路径

  • SUN:JAVA_HOME是包含JRE的目录

因此我有2个关于此问题的问题(任何见解都会受到欢迎,但具体来说,我有这两个问题):

I thus have 2 questions regarding this matter (any insights would be welcome, also, but concretely, I have these two questions) :

1)mac os X java安装是否从目标复制目标JavaVM.frameworks目录进入usr / bin?

1) Does mac os X java installation copy the target from the "JavaVM.frameworks" directory into usr/bin ?

2)JAVA_HOME的定义是什么?显然,我们不能将JAVA_HOME简单地定义为安装java的地方,因为这个定义是模糊的,因为java既可以存在于HOME位置(即/ System / Library / Fraemworks / .....),也可以或者,它也可以直接在/ usr / bin目录中?

2) What is the "definition" of JAVA_HOME ? Clearly, we cannot define JAVA_HOME as simply "the place where java is installed", because this definition is ambiguous, since java can exist both in a HOME location (i.e. in /System/Library/Fraemworks/.....) , or alternatively, it may also be directly in the /usr/bin directory ?

我的想法

我认为JAVA_HOME实际上是指不仅仅是指二进制java程序。 JAVA_HOME可能是指一组java相关目录和二进制文件的位置...但是,我仍然不清楚这包含了什么,而且我提议的这个定义是否足够精确到有用。

I believe that JAVA_HOME is ACTUALLY meant to refer to more than just a binary "java" program. JAVA_HOME probably is meant to refer to the location of a set of java related directories AND binaries... But still, I am not really clear what this comprises, and wether or not this definition which I am proposing is precise enough to be useful.

推荐答案

JAVA_HOME 没有真实的定义。 Java Runtime Environment不使用此变量,并且没有规范作为Java平台的一部分。

There is no "true" definition of JAVA_HOME. This variable is not used by the Java Runtime Environment, and has no specification as part of the Java platform.

它只是一些在Java平台上运行的应用程序使用的约定。由于没有标准,每个应用程序都可以自由地制定关于此变量应该引用的目录的规则;你应该阅读应用程序的文档以找出它需要的内容。

It is merely a convention that is used by some applications that run on top of the Java platform. Since there's no standard, each application is free to make its own rules about the directory to which this variable should refer; you should read the application's documentation to find out what it needs.

也就是说,我发现使用这个变量的每个应用程序如果你把它设置到顶部就行了JDK安装的级别目录(不是JDK中的JRE,而是JDK本身)。该目录应包含bin和lib子目录,它们分别包含 java 可执行文件和运行时库。

That said, every application I've found that uses this variable will work if you set it to the top level directory of a JDK installation (not the JRE within the JDK, but the JDK itself). This directory should contain "bin" and "lib" subdirectories that contain the java executable and the runtime libraries, respectively.

如果你将它指向JRE,某些应用程序也会起作用,但是如果它需要像 javac 这样的开发工具,它将会失败。

Some applications will also work if you point it at a JRE, but if it needs development tools like javac, it will fail.

通常,当我运行一个比需要它的工具时,我在命令行上指定 JAVA_HOME ,因为我使用多个版本的Java,如下所示: / p>

Usually, I specify JAVA_HOME on the command line when I run a tool than needs it, because I work with multiple versions of Java, like this:

JAVA_HOME=/usr/local/jdk1.6.0_29 ant

这篇关于走向“真实” JAVA_HOME的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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