Why am I getting "Error: Could not find or load main class org.apache.tools.ant.launch.Launcher" on Red Hat Enterprise Linux 6?

Solution Verified - Updated -

Issue

  • Why does Java applications give an error Error: Could not find or load main class org.apache.tools.ant.launch.Launcher on RHEL 6?
  • Ant doesn't not run with Java 8.
# ant -version
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
# ant --execdebug
exec "/usr/lib/jvm/java/bin/java" -classpath "/usr/bin/build-classpath: error: JAVAVER_LIBDIR /usr/share/java-1.8.0 does not exist or is not a directory:/usr/bin/build-classpath: error: JAVAVER_LIBDIR /usr/share/java-1.8.0 does not exist or is not a directory:/usr/lib/jvm/java/lib/tools.jar" -Dant.home="/usr/share/ant" -Dant.library.dir="/usr/share/ant/lib" org.apache.tools.ant.launch.Launcher -cp ""
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher

Environment

  • Red Hat Enterprise Linux 6
  • jpackage-utils-1.7.5-3.12.el6.noarch
  • OpenJDK 8
  • Oracle Java 8
  • Ant
  • Tomcat 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.