Towards the “true” definition of JAVA_HOME

前端 未结 5 1125
青春惊慌失措
青春惊慌失措 2020-12-06 17:17

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

5条回答
  •  情歌与酒
    2020-12-06 17:54

    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.

    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.

    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.

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

    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
    

提交回复
热议问题