Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 30772 - emerge ant fails with "Warning: JAVA_HOME environment variable not set."
Summary: emerge ant fails with "Warning: JAVA_HOME environment variable not set."
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Java team
Depends on:
Reported: 2003-10-09 11:05 UTC by Steven Elling
Modified: 2004-01-30 17:12 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---

Not very ideal patch for the ebuild (ant-1.5.3-r5.ebuild.patch,763 bytes, patch)
2003-10-09 11:13 UTC, Steven Elling
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Elling 2003-10-09 11:05:16 UTC
When emerging ant 1.5.3-r5, it fails because the ebuild sets JAVA_HOME to JDK_HOME, which 
is undefined in my case.  I made changes to the ebuild to set JAVA_HOME to the location of 
the installed Java Development Kit but it still failed. 
I found out the reason why the ebuild failed was because my system's Java environment was 
set to "blackdown-jre-1.4.1".  I pulled out the changes to the ebuild and added others to check 
the Java environment.  After changing the Java environment to "blackdown-jdk-1.4.1" using 
"java-config --set-system-vm=blackdown-jdk-1.4.1", ant installed with the modified ebuild. 

Reproducible: Always
Steps to Reproduce:
1. Set your Java Environment to blackdown-jre-1.4.1 
2. emerge ant 
Actual Results:  
>>> Unpacking source... 
>>> Unpacking apache-ant-1.5.3-1-src.tar.bz2 to /var/tmp/portage/ant-1.5.3-r5/work 
 * Applying [ ok ] 
 * Applying 1_6_backport-jdk142.patch.gz... [ ok ] 
>>> Source unpacked. 
Warning: JAVA_HOME environment variable not set. 
  If build fails because sun.* classes could not be found 
  you will need to set the JAVA_HOME environment variable 
  to the installation directory of java. 
Error: JAVA_HOME is not defined correctly. 
  We cannot execute java 
Bootstrap FAILED 
!!! ERROR: dev-java/ant-1.5.3-r5 failed. 
!!! Function src_compile, Line 79, Exitcode 1 
!!! (no error message) 

Expected Results:  
IMHO, the ant ebuild should of recognized the Java JDK was installed regardless of which Java 
enviroment was seleted.
Comment 1 Steven Elling 2003-10-09 11:13:22 UTC
Created attachment 19022 [details, diff]
Not very ideal patch for the ebuild

This patch is not ideal because an admin cannot start an emerge (i.e. xalan)
upgrade that depends on ant and walk away while it runs.

The patch adds a check to pkg_setup() to verify which Java environment is
selected and fail if the correct one is not selected.

The setting of JAVA_HOME to JDK_HOME was removed because it is redundant.
Comment 2 Steven Elling 2003-10-09 11:15:33 UTC
Also, 'java-config --list-available-packages' is now borked after the install.

'java-config --list-available-packages' produces the following output:

[ant] Java-based build tool similar to 'make' that uses XML configuration
files. (/usr/share/ant/package.env)
[fop] "" (/usr/share/fop/package.env)
[saxon] The SAXON package is a collection of tools for processing XML documents:
XSLT processor, XSL library, parser. (/usr/share/saxon/package.env)
Comment 3 Steven Elling 2003-10-09 11:19:00 UTC
Disregard that last comment about "java-config --list-available-packages".

I was thinking "java-config --list-available-vms" but using "java-config
--list-available-packages" instead.  My bad.
Comment 4 Radoslaw Szkodzinski 2003-11-05 13:27:47 UTC
It is caused by blackdown-jdk not adding its environment vars to /etc/env.d
but to /etc/env.d/java.
env-update doesn't process subdirs it seems.
Just copy the file to proceed.
Comment 5 Adrian Almenar 2003-12-15 18:40:59 UTC
After setting the VM with java-config did you made env-update && source /et/profile ???
Comment 6 Adrian Almenar 2003-12-19 21:55:22 UTC
Moving this again to, so everyone out there can help.
Comment 7 Adrian Almenar 2004-01-25 00:22:03 UTC
I think that if you emerge ant, it will need a vm an it will install the default one. If a user changes the default system VM ant its not responsible of checking it cause it was installed correctly, but the user broke the configuration.

If this error is checked here, it will need to be checked on every java ebuild, so its not an option.
Comment 8 Steven Elling 2004-01-30 17:12:54 UTC
Well the thing of it is I didn't change the default VM before I had problems with ant.

I think the first time blackdown-jre-1.4.1 was required by an ebuild was when I installed OpenOffice-bin. Another package I installed later on depended on blackdown-jdk-1.4.1 but the Java VM was not changed by the ebuild.  I can't remember which package it was.