Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant unable to launch, giving a main class error

Tags:

java

ant

I'm running Elementary OS (Ubuntu 12 based), and I'm having issues running apache ant. It was working earlier before a restart, so I'm not sure what would've changed.

I've defined environment variables in /etc/environment as follows:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$ANT_HOME/bin"
JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386"
ANT_HOME="/opt/ant"
ANT_OPTS="-Xms256M -Xmx512M"

So my Java and Ant environment variables should be set. I'm trying to deploy with ant, with 'ant clean deploy', but I get an error in my terminal:

Error: Could not find or load main class org.apache.tools.ant.launch.Launcher

I've tried "source /etc/environment". Running 'echo $ANT_HOME' shows the correct path. I've tried moving ant to a different location and resetting the variables. Nothing. I'm kind of lost. Please help!

like image 656
Noah Avatar asked Nov 26 '25 02:11

Noah


1 Answers

you should define $ANT_HOME before using it in your $PATH

  JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386"
  ANT_HOME="/opt/ant"
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$ANT_HOME/bin"

double check that you have ant-launcher.jar under $ANT_HOME/lib

like image 172
Frederic Close Avatar answered Nov 28 '25 16:11

Frederic Close



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!