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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content