When running maven (2.0.4) it picks up the system default JVM settings (1.4) rather than the user specific settings (1.5). This means I cannot compile projects to target source of 1.5 for example. Partial output follows: [INFO] [compiler:compile] Compiling 50 source files to /home/darren/projects/javabot/target/classes [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure Failure executing javac, but could not parse the error: javac: invalid target release: 1.5 Usage: javac <options> <source files> /usr/bin/mvn has the following code that sets the VM: if [ -z "$JAVA_HOME" ] ; then if [ -e /etc/gentoo-release ] ; then JAVA_HOME=`java-config --jre-home` fi fi This picks up my 1.4.12 system VM when run as part of this script, but when run interactively, the java-config command correctly obtains my 1.5 JVM: darren@garbo ~ $ java-config --jre-home /opt/sun-jdk-1.5.0.07 This may be a general java-config issue, I don't know. Hopefully relevant info below.. darren@garbo ~ $ emerge -s java-config Searching... [ Results for search key : java-config ] [ Applications found : 2 ] * dev-java/java-config Latest version available: 2.0.26-r4 Latest version installed: 2.0.26-r4 Size of files: 14 kB Homepage: http://www.gentoo.org/proj/en/java/ Description: Java environment configuration tool License: GPL-2 * dev-java/java-config-wrapper Latest version available: 0.10-r1 Latest version installed: 0.10-r1 Size of files: 5 kB Homepage: http://www.gentoo.org/proj/en/java Description: Wrapper for java-config License: GPL-2 darren@garbo ~ $ java-config-2 -L 1) Sun JDK 1.4.2.12 [sun-jdk-1.4] (/usr/share/java-config-2/vm/sun-jdk-1.4) *) Sun JDK 1.5.0.07 [sun-jdk-1.5] (/usr/share/java-config-2/vm/sun-jdk-1.5) darren@garbo ~ $ java-config-1 -L [sun-jdk-1.4.2.12] "Sun JDK 1.4.2.12" (/etc/env.d/java/20sun-jdk-1.4.2.12) * darren@garbo ~ $ emerge --info Portage 2.1-r1 (default-linux/x86/2006.0, gcc-3.4.6, glibc-2.3.6-r4, 2.6.15-gentoo-r1 i686) ================================================================= System uname: 2.6.15-gentoo-r1 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz Gentoo Base System version 1.6.15 ccache version 2.3 [enabled] app-admin/eselect-compiler: [Not Present] dev-lang/python: 2.3.5-r2, 2.4.3-r1 dev-python/pycrypto: 2.0.1-r5 dev-util/ccache: 2.3 dev-util/confcache: [Not Present] sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.59-r7 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2 sys-devel/binutils: 2.16.1-r3 sys-devel/gcc-config: 1.3.13-r3 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.11-r2 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config" CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/splash /etc/terminfo" CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig candy ccache distlocks metadata-transfer sandbox sfperms strict" GENTOO_MIRRORS="ftp://bacall.davisononline.org ftp://ftp.mirror.ac.uk/mirror/distro.ibiblio.org/pub/linux/distributions/gentoo/ ftp://mirrors.blueyonder.co.uk/mirrors/gentoo ftp://ftp.heanet.ie/pub/gentoo/" LANG="en_GB" LC_ALL="en_GB" PKGDIR="/usr/portage/packages" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'" PORTAGE_TMPDIR="/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://bacall.davisononline.org/usr-portage" USE="X alsa apm avi bitmap-fonts cdr cli crypt dlloader dri dvd emboss encode esd flac foomaticdb fortran ftp gdbm gif gpm gstreamer gtk gtk2 hal imap imlib ipv6 isdnlog jpeg kde kdexdeltas ldap libg++ libwww mad mikmod motif mp3 mpeg ncurses nls nptl ogg oggvorbis opengl oss pam pcre pdflib perl png pppd python qt qt3 qt4 quicktime readline reflection sdl session spell spl sse ssl tcpd tidy truetype truetype-fonts type1-fonts udev unicode usb vorbis x86 xml xorg xv zlib elibc_glibc input_devices_keyboard input_devices_mouse kernel_linux userland_GNU video_cards_i810" Unset: CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LDFLAGS, LINGUAS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS
dammit, this may be a false report. JAVA_HOME is incorrectly set in my environment to the 1.4.12 system VM (or perhaps it's meant to be that way, I don't know) but the mvn shell scrip never executes java-config --jre-home because JAVA_HOME is already set. To workaround, I've now added export JAVA_HOME="" to my ~/.bashrc and maven behaves as expected. Apologies for not realising this sooner; I guess it's just a question of whether JAVA_HOME should be set that way by default or not.
JAVA_HOME is used by generation 1 (old system) only - it's safe to unset it for users, but not for root (java-config-1 relies upon it). After migration is completed and java-config-1* is removed the problem will be gone. Until then it's quite hard to fix it.