Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set the environment variable ANT_OPTS in ubuntu?

while setting up liferay environment in Ubuntu 10.0.4, i have set the environment variables like this in .bashrc file

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:

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
like image 880
ASR Avatar asked Apr 07 '14 06:04

ASR


People also ask

What is Ant_opts?

ANT_OPTS is a list of arguments that you want to pass to the JVM that will run Ant. • JAVACMD is the absolute path to the Java executable you want Ant to use. you may specify a value for the JAVACMD environment variable.

Where is Ant home in Linux?

On Windows it would be easy to find the correct folder -- ANT_HOME is the folder, where the installation is stored and looks like C:\Program Files\Apache Ant (or simply the parent directory of the folder with the Ant binaries).

How do I set an ant environment variable in Windows?

Choose Start -> Control Panel, and double-click the System icon. Click the Advanced tab, and then click the Environment Variables button. Under System Variables, select New to create the ANT_HOME environment variable.


2 Answers

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..

like image 180
ASR Avatar answered Sep 28 '22 12:09

ASR


I see several problems in your .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 and ANT_HOME
  • @fge already pointed to set path=$path $ANT_HOME/bin. This would be rather PATH=$PATH:$ANT_HOME/bin

And finally the error message, the only difference is just 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

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.

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

like image 36
Olaf Dietsche Avatar answered Sep 28 '22 12:09

Olaf Dietsche