如何在 Mac OS X 上安装 Apache Ant? [英] How can I install Apache Ant on Mac OS X?

查看:27
本文介绍了如何在 Mac OS X 上安装 Apache Ant?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的 Mac 上安装 Apache Ant,并按照以下步骤操作:

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

  1. 我将 apache-ant-1.8.1-bin.tar.gz 下载到我的下载文件夹中.
  2. 我使用以下命令将文件移动到 /usr/local/:sudo shmv apache-ant-1.8.1-bin.tar.gz/usr/local/
  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/

现在我想使用 cd/usr/local/ 但它不起作用,我回复没有这样的文件或目录".

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

然后我使用了 cd/usr/ls 命令,看起来本地文件夹就在那里.如果我尝试访问它,我会遇到同样的错误.

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.

既然我已经使用了 sudo su 为什么我无法访问它?有什么想法吗?

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

推荐答案

Ant 已经安装在一些旧版本的 Mac OS X 上,所以你应该运行 ant -version 来测试它是否安装在尝试安装之前.

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.

如果尚未安装,那么最好的办法是安装 Homebrew (brew install ant) 或 MacPorts (sudo port install apache-ant),然后使用安装 Apache Ant 的工具.

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.

或者,虽然我强烈建议改用 Homebrew 或 MacPorts,但您可以手动安装 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. 解压 .tar.gz 文件.
  2. 可以选择把它放在某个地方.
  3. 将bin"放入路径中的子目录.

假设 apache-ant-1.8.1-bin.tar.gz(用实际版本替换 1.8.1)仍然在您的下载目录中,您需要的命令将是以下(包括解释性评论):

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

这篇关于如何在 Mac OS X 上安装 Apache Ant?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆