• 0
name Punditsdkoslkdosdkoskdo

How can I install Apache Ant on Mac OS X?

I tried to install Apache Ant on my Mac and I followed the next steps :

  1. I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder.
  2. I moved the file to /usr/local/ using this commands : sudo sh and mv apache-ant-1.8.1-bin.tar.gz /usr/local/

Now I want to use cd /usr/local/ but it's not working, I get back "No such file or directory".

Then I used cd /usr/ and ls commands and it seems that the local folder is there. If I try to access it I get the same error.

Since I already used sudo su why I can't access it? Any ideas?

Ant is already installed on some older versions of Mac OS X, so you should run ant -version to test if it is installed before attempting to install it.

If it is not already installed, then your best bet is to install Homebrew (brew install ant) or MacPorts (sudo port install apache-ant), and use those tools to install Apache Ant.

Alternatively, though I would highly advise using Homebrew or MacPorts instead, you can install Apache Ant manually. To do so, you would need to:

  1. Decompress the .tar.gz file.
  2. Optionally put it somewhere.
  3. Put the "bin" subdirectory in your path.

The commands that you would need, assuming apache-ant-1.8.1-bin.tar.gz (replace 1.8.1 with the actual version) were still in your Downloads directory, would be the following (explanatory comments included):

cd ~/Downloads # Let's get into your downloads folder.
tar -xvzf apache-ant-1.8.1-bin.tar.gz # Extract the folder
sudo mkdir -p /usr/local # Ensure that /usr/local exists
sudo cp -rf apache-ant-1.8.1-bin /usr/local/apache-ant # Copy it into /usr/local
# Add the new version of Ant to current terminal session
export PATH=/usr/local/apache-ant/bin:"$PATH"
# Add the new version of Ant to future terminal sessions
echo 'export PATH=/usr/local/apache-ant/bin:"$PATH"' >> ~/.profile
# Verify new version of ant
ant -version
  • 0
Reply Report