how to set the environment variable ANT_OPTS in ubuntu?

14,433

Solution 1

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

Solution 2

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

Share:
14,433

Related videos on Youtube

ASR
Author by

ASR

Updated on September 15, 2022

Comments

  • ASR
    ASR over 1 year

    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
    
  • ASR
    ASR about 10 years
    changed from path=$path $ANT_HOME/bin to PATH=$PATH:$ANT_HOME/bin still getting same error
  • Olaf Dietsche
    Olaf Dietsche about 10 years
    These two are unrelated, I only wanted to point out some problematic parts. For the error message, you must only change 256 to 512.
  • Olaf Kock
    Olaf Kock about 10 years
    @ASR So what problem remains? The situation you mention just demands to change 256 to 512. You should either have a working system now (then please accept this answer) or run into a different problem. In that case, please edit the question or ask a new question with the new error message