You may be surprised to learn Ant requires GCJ when installed through Synaptic or apt on Ubuntu.  GCJ is GNU’s Java compiler.  When you’re using Sun’s JDK and compiler, GCJ can get in the way — at worst it creates conflicts; at best it causes confusion.

Here’s how I installed Ant on Ubuntu without GCJ. Be sure to check out (easier) alternatives suggested in the comments, below.

  1. Download the current .tar.bz2 distribution of Ant from http://www.ibiblio.org/pub/mirrors/apache/ant/binaries/.
  2. Unpack archive using tar.
  3. tar -xjvf apache-ant-*-bin.tar.bz2
  4. Move the unpacked directory to /usr/local/ant.
  5. Change that directory’s owner to root.
  6. chown -R root:root /usr/local/ant
  7. Add the following lines to /etc/bash.bashrc.
  8. export ANT_HOME=/usr/local/ant
    export PATH=${PATH}:${ANT_HOME}/bin

From a new shell, run ant. You should see the following:

Buildfile: build.xml does not exist!
Build failed

Yes, it’s a failure message. But it means Ant is working as expected. :)

  5 Responses to “Ant on Ubuntu without GCJ”

  1. What about sudo apt-get install –no-install-recommends ant ?

  2. He-s right, that method is, I think, more biginner-friendly. Find it over here:
    http://picobit.wordpress.com/2009/04/08/ubuntu-eclipse-and-ant-without-gcj/

    This way, you get updates with the other packages.

  3. Thanks for the (easier) alternative!

  4. For some strange reason my apt-get and aptitude does not recognize any ‘recommends’ option, even though the help says it should…

  5. ‘apt-get install –no-install-recommends maven2′ does the trick for me. Seems like some blogging software replaces the double-dash in front of the option with ONE dash and that doesn’t work (yeah, it took me 2 hours to get this right)

    just watch that there’s a double-dash in front of the no-install-recommends!

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

 
© 2011 And now here's something… Suffusion theme by Sayontan Sinha