Java 如何在ubuntu中设置环境变量ANT_OPTS?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22905328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to set the environment variable ANT_OPTS in ubuntu?
提问by ASR
while setting up liferay environment in Ubuntu 10.0.4, i have set the environment variables like this in .bashrc file
在 Ubuntu 10.0.4 中设置 liferay 环境时,我在 .bashrc 文件中设置了这样的环境变量
PATH=/usr/bin/java/jdk1.7.0_51/bin:$PATH
export PATH
JAVA_HOME=/usr/bin/java/jdk1.7.0_51
export JAVA_HOME
PATH=/usr/bin/ant/bin:$PATH
export PATH
ANT_HOME=/usr/bin/ant
export ANT_HOME
ANT_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
export ANT_OPTS
set path=$path $ANT_HOME/bin
i have tested environment variables like this in my terminal:
我在终端中测试了这样的环境变量:
sudheer@VY-B3:~$ echo $PATH
/usr/bin/ant/bin:/usr/bin/java/jdk1.7.0_51/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
sudheer@VY-B3:~$ echo $JAVA_HOME
/usr/bin/java/jdk1.7.0_51
sudheer@VY-B3:~$ echo $ANT_HOME
/usr/bin/ant
sudheer@VY-B3:~$ echo $ANT_OPTS
-Xmx1024m -XX:MaxPermSize=256m
while running build-themes for liferay getting following error:
在为 liferay 运行构建主题时出现以下错误:
Buildfile: /home/sudheer/Desktop/Life-ray/Liferay_workspace/portal/portal-web/build.xml
BUILD FAILED
/home/sudheer/Desktop/Life-ray/Liferay_workspace/portal/portal-web/build.xml:4: The following error occurred while executing this line:
/home/sudheer/Desktop/Life-ray/Liferay_workspace/portal/build-common-web.xml:4: The following error occurred while executing this line:
/home/sudheer/Desktop/Life-ray/Liferay_workspace/portal/build-common.xml:393: .
Please set the environment variable ANT_OPTS to the recommended value of
"-Xmx1024m -XX:MaxPermSize=512m".
Total time: 2 seconds
采纳答案by ASR
lastly i have stetted the environment variables like this:
最后,我已经设置了这样的环境变量:
# Java environment variables
JAVA_HOME=/opt/java/jdk1.7.0_51
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
ANT_HOME=/opt/apache-ant-1.7.1
export ANT_HOME
PATH=$ANT_HOME/bin:$PATH
export PATH
ANT_OPTS="-Xmx1024m -XX:MaxPermSize=512m"
export ANT_OPTS
in the .bashrc file, i have opened the eclipse in terminal.. now its working fine..
在 .bashrc 文件中,我在终端中打开了 eclipse.. 现在它工作正常..
回答by Olaf Dietsche
I see several problems in your .bashrc
我在你的 .bashrc 中看到了几个问题
/usr/bin/java/jdk1.7.0_51/bin
doesn't look right./usr/bin
is for executable files. Usually this is something like/usr/lib/java/...
or/usr/lib/jvm/...
- same for
JAVA_HOME
andANT_HOME
- @fge already pointed to
set path=$path $ANT_HOME/bin
. This would be ratherPATH=$PATH:$ANT_HOME/bin
/usr/bin/java/jdk1.7.0_51/bin
看起来不对。/usr/bin
用于可执行文件。通常这类似于/usr/lib/java/...
或/usr/lib/jvm/...
- 同为
JAVA_HOME
和ANT_HOME
- @fge 已经指向
set path=$path $ANT_HOME/bin
. 这将是PATH=$PATH:$ANT_HOME/bin
And finally the error message, the only difference is just 512m
vs 256m
.
最后是错误消息,唯一的区别只是512m
vs 256m
。
Update:
更新:
I just looked in my system (Ubuntu 12.04), ant is located below /usr/share/ant
, so for ant this would be
我刚刚查看了我的系统(Ubuntu 12.04),蚂蚁位于下面/usr/share/ant
,所以对于蚂蚁来说,这将是
ANT_HOME=/usr/share/ant
Although, if you installed the ant package via package management, there should be no need to set ANT_HOME
and PATH
.
虽然,如果您通过包管理安装了 ant 包,则不需要设置ANT_HOME
和PATH
。
Update:
更新:
If you run ant from eclipse, .bashrc might not be loaded, unless you start eclipse from the command line. .bashrc is only loaded for an interactive bash shell, see Bash Startup Files
如果您从 eclipse 运行 ant,则可能不会加载 .bashrc,除非您从命令行启动 eclipse。.bashrc 仅为交互式 bash shell 加载,请参阅Bash 启动文件