Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#44806 - [java-runtime-common] JAVA_HOME environment variable not set
Attached to Project:
Arch Linux
Opened by David Sankel (sankeld) - Friday, 01 May 2015, 19:09 GMT
Last edited by Guillaume ALAUX (galaux) - Saturday, 30 May 2015, 11:46 GMT
Opened by David Sankel (sankeld) - Friday, 01 May 2015, 19:09 GMT
Last edited by Guillaume ALAUX (galaux) - Saturday, 30 May 2015, 11:46 GMT
|
DetailsDescription:
With the new java infrastructure, the environment variable 'JAVA_HOME' is not set. This causes problems with packages, such as CMake, which use this to discover the java location. The fix, which I think is general, would be to update the '/etc/profile.d/jre.sh' file to set 'JAVA_HOME' to '/usr/lib/jvm/java-default-runtime'. Steps to reproduce: Create a new 'CMakeLists.txt' file with the contents 'find_package( JRE required )' and note the error. |
This task depends upon
There was a mistake in the initial "Steps to reproduce" section. Attached is a minimal 'CMakeLists.txt' that reproduces the error. Put it in an empty directory and type 'cmake .'.
CMake Error at /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
Call Stack (most recent call first):
/usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.2/Modules/FindJNI.cmake:287 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:2 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/david/tmp/CMakeFiles/CMakeOutput.log".
If 'JAVA_HOME' is set in the environment, the error goes away: 'JAVA_HOME=/usr/lib/jvm/default cmake .'
-- Found JNI: /usr/lib64/jvm/default/jre/lib/amd64/libjawt.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/david/tmp
Does it sound right to you?
CMake sensibly uses this information to figure out where to find the default Java development libraries. If someone wants to override these, the proper process is to use CMake variables; not to modify the JAVA_HOME environment variable as you indicated.
Other Arch users have had related problems that also also point to the fact that applications use JAVA_HOME to discover the location of the default java installation on a system. For java applications, using java in the path is just fine. For JNI applications and development tools like CMake, however, discovery of the installation path is necessary and this is done by using JAVA_HOME. All other distributions that I know of except recent versions of Arch set JAVA_HOME properly.
The other examples you cited (CFLAGS, etc.) are extension points and not system configuration variables as JAVA_HOME is.
About Archers having related problems due to applications using JAVA_HOME to discover the location of the default java installation on a system. Java end user applications doing so is a bad practice. End user application do not need to know where the JRE is installed. They just need to call `java` with the appropriate option. If the JRE package is cleanly installed, the `java` binary will be found and the application will start. Just like when you run `ls`. No matter where it is installed, you just run `ls` and your distro takes care of the rest whether `ls` is installed in `/usr/bin`, `/usr/local/bin`, `/bin` or wherever. The only explanation I can think of for Java applications trying to figure out where the JRE dates from the early days of JRE/JDK when they were not yet common on Linux distributions. People usually downloaded tarballs and extracted it here or there without always thinking about the PATH. So when you wanted to provide a Java end user app, you could not rely on PATH to find `java` – this is my own explanation, I might be totally wrong on this reason but it does not effect the fact that Java end user app do not need to know where the JRE is installed.
As for JNI and development tools like CMake I agree that discovery of the java home is done through the JAVA_HOME variable. I just think this is a system build environment variable that should be setup by hand if one needs it.
> All other distributions that I know of except recent versions of Arch set JAVA_HOME properly.
You might want to check that! http://pastebin.com/fbnRVtSu