On my 64bit CentOS 5.4 linux install just installing ant and tomcat fails.
It fails when I go to start the tomcat service or just run ant.

I tried many different things to fix the problem, including removing all the jre/jdks/ant/open jdks and sun jdk’s. My original solution was to stop using the rpm’s and just download direct from apache (and in the case of ant, set ANT_HOME and JAVA_HOME in /usr/local/apache-ant-version/bin/ant). A typical error would look like this:

[cameron@mars java]$ /usr/bin/ant
/usr/bin/build-classpath: error: JAVA_LIBDIR must be set
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher
 at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
[cameron@mars java]$

I have two systems that I set up basically identically, it worked fine on one (a parallels jvm running centos 5.4 64bit on my macbook pro) and nothing but problems with a native install. In the end the solution was very simple.

edit your /etc/java/java.conf file.

/etc/java/java.conf

# System-wide Java configuration file                                -*- sh -*-
#
# JPackage Project 

# Location of jar files on the system
JAVA_LIBDIR=/usr/share/java

# Location of arch-specific jar files on the system
JNI_LIBDIR=/usr/lib/java

# Root of all JVM installations
JVM_ROOT=/usr/lib/jvm

# You can define a system-wide JVM root here if you're not using the default one
#JAVA_HOME=$JVM_ROOT/java

# Options to pass to the java interpreter
JAVACMD_OPTS=

Leave a Reply