Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher

I've installed ubuntu 10.10 in my system and installed ant with the following command: sudo apt-get install ant

Now, ant is visible in the share folder, so I've tried to run the ant command in terminal, but it gives me this error:

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:202)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.tools.ant.launch.Launcher.  Program will exit.

Then I set these again:

JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.22/"
ANT_HOME="/usr/share/ant/"
PATH="/usr/share/ant/bin/"

Now it is giving me the same error but with one different line at starting:

/usr/share/ant/bin/ant: 92: uname: not found
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:202)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.tools.ant.launch.Launcher.  Program will exit.
like image 409
Swathi EP Avatar asked Nov 18 '10 12:11

Swathi EP


1 Answers

try the following:

JAVA_HOME="/usr/lib/jvm/java-6-sun"
ANT_HOME="/usr/share/ant" # do not add "bin" at the end of the path**
PATH="$ANT_HOME/bin:$PATH"
like image 72
Mr Lou Avatar answered Oct 15 '22 17:10

Mr Lou