我之前用过brew来安装ant。当我运行brew install ant
时,我得到:
"Warning: ant-1.9.7 already installed"
但是,如果我运行ant -v
,我会:
Exception in thread "main" java.lang.NoClassDefFoundError: Xms256M
Caused by: java.lang.ClassNotFoundException: Xms256M
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
供参考,这是我的bash档案:
ANT_HOME=/Users/name/Documents
ANT_OPTS="-Xms256M -Xmx512M"
PATH=$PATH:$HOME/bin:$ANT_HOME/bin
export ANT_HOME ANT_OPTS PATH
[[ -s ~/.bashrc ]] && source ~/.bashrc
# Enable tab completion
source ~/git-completion.bash
# colors
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
reset="\[\033[0m\]"
# Change command prompt
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# '\u' adds the name of the current user to the prompt
# '\$(__git_ps1)' adds git-related stuff
# '\W' adds the name of the current directory
export PATH="/usr/local/sbin:$PATH"
有人能告诉我哪里出错了?
答案 0 :(得分:0)
您为环境变量ANT_OPTS
设置的值不正确。在-
而不是Xms256M
-Xms256M
请确保ANT_OPTS
具有正确的价值。
例如:下面将最小和最大堆大小设置为256MB。
export ANT_OPTS="-Xms256M -Xmx256M"
答案 1 :(得分:0)
我意识到问题是因为我忘了将“apache-ant-1.9.7”添加到我的.bash_profile中的ant位置路径的末尾。例如
ANT_HOME=/Users/MyName/Documents/apache-ant-1.9.7