Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6772001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:29:54+00:00 2026-05-26T15:29:54+00:00

I am having a problem accessing environment variables in a netbeans build.xml ant script.

  • 0

I am having a problem accessing environment variables in a netbeans build.xml ant script. Basically, when I use this code:

<target name="-pre-jar">

    <property environment="env"/>

    <echo message="${env.ANT_HOME}"/>
    <echo message="${env.JAVA_HOME}"/>

</target>

I receive output as follows:

compile:
${env.ANT_HOME}
${env.JAVA_HOME}

This is a problem because I need to access those filepaths later in the script. Also, I am sure that those two are defined as environment variables. Here is some proof from my terminal:

Lukas-Rezeks-MacBook-Pro:ant lukas$ echo $JAVA_HOME - $ANT_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home - /ant

Am I doing something wrong in the ant build scripts variable declaration, or am I missing something obvious? Any feedback would be appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:29:54+00:00Added an answer on May 26, 2026 at 3:29 pm

    You can either put

    <property environment="env"/>
    

    outside your target,

    OR use “depends=” instead of “antcall” in your compile task.

    I did the following test on my Linux:

    <target name="pre-jar">
        <property environment="env"/>
        <echo message="${env.ANT_HOME}"/>
        <echo message="${env.JAVA_HOME}"/>
    </target>
    
    <target name="compile">
        <antcall target="pre-jar" />
        <echo message="${env.ANT_HOME}"/>
        <echo message="${env.JAVA_HOME}"/>
    </target>
    

    and when I ran “ant compile” I got the following:

    compile:

    pre-jar:
    [echo] /opt/apache-ant-1.8.2
    [echo] /opt/jdk1.7.0
    [echo] ${env.ANT_HOME}
    [echo] ${env.JAVA_HOME}

    and when I used depends=”pre-jar”, the result was:

    pre-jar:
    [echo] /opt/apache-ant-1.8.2
    [echo] /opt/jdk1.7.0

    compile:
    [echo] /opt/apache-ant-1.8.2
    [echo] /opt/jdk1.7.0

    when I put outside any target, the result was:

    compile:

    pre-jar:
    [echo] /opt/apache-ant-1.8.2
    [echo] /opt/jdk1.7.0
    [echo] /opt/apache-ant-1.8.2
    [echo] /opt/jdk1.7.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may look a very basic question but I am having a problem accessing
I am having a problem accessing a static const variable defined in my class
I am having a problem accessing the @attribute section of my SimpleXML object. When
I am having a problem accessing the ViewData object through javascript. I have set
I am having a problem with the speed of accessing an association property with
I'm having problem accessing the usual properties like frame, bounds, origin, size, etc etc.
In Rails 3, I am having a problem accessing a helper method from within
http://en.wikipedia.org/wiki/Special_Folders I am having a problem with accessing a special folder in a fopen
I'm having an issue accessing raw request information from PHP when accessing a script
I am having a problem in getting GPS coordinates in 2.1. The code i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.