Loading Environment Variables in java through the Ant script

576 views Asked by At

I'm using jibx to convert a xml to JAVA and vice versa. Here, in an Ant script, I'm using the following code to load the JIBX_HOME path from the environment variable:

<property environment="env"/>
<property name="jibx-home" value="${env.JIBX_HOME}"/>

I have set the JIBX_HOME environment variable to .bashrc as follows:

export JIBX_HOME=/rezsystem/jibx_1_2_2/jibx

But this path is not loaded to the jibx-home property. When I simply type $ set command in the terminal it prints. JIBX_HOME=/rezsystem/jibx_1_2_2/jibx successfully. What have I missed here? My OS is Ubuntu 12.10 and my IDE is Eclipse kepler.

5

There are 5 answers

0
Supun Sameera On BEST ANSWER

Make sure you add the line to the current bashrc like, key in on a shell,

vi ~/.bashrc

or

gedit ~/.bashrc

then enter the line at the end,

export JIBX_HOME=/rezsystem/jibx_1_2_2/jibx

don't use sudo command, save the file and restart the system.

1
quotidian-ennui On

If you print out the environment property using echo then is it set properly?

Ant properties are immutable anyway so you can just remove the entire not condition as you can't override the jibx-home property using your condition.

0
Claudiu On

Try running eclipse with:

    bash -ic "path to eclipse" 

Do this after exporting JIBX_HOME variable.

I had to change my link to eclipse to this because it was not loading all env variables.

0
Simmant On

I think you also have to add your environment variable with PATH also

like:

export JIBX_HOME=/rezsystem/jibx_1_2_2/jibx

export PATH=$PATH:$JIBX_HOME
2
carlspring On

Try setting these environment variables in your .bash_profile instead.