Skip to content Skip to sidebar Skip to footer

Ant Flagrantly Ignoring Java_home Environment Variable

I just picked up the latest version of the Android SDK and started trying to use it. Unlike almost everyone else coming up with this problem, I'm running Linux, namely Linux Mint 1

Solution 1:

The chances are that ant is telling the truth and that the environment variable is not set. The chances are that:

  • you put the wrong statement into the ".bashrc" file, or
  • you didn't restart properly.

Anyway, you can verify this by running export in the shell before to run the ant command ... and looking to see if the JAVA_HOME variable is listed.


Hints:

1) This is wrong:

JAVA_HOME=/usr/java/jdk1.7.0_05/

That only creates a local shell variable, and local shell variables are NOT passed to child process (like the ant command). It should be:

exportJAVA_HOME=/usr/java/jdk1.7.0_05/

2) Try running this:

exportJAVA_HOME=/usr/java/jdk1.7.0_05/
ant

3) Adding java.home=/usr/java/jdk1.7.0_05/ to ant.properties won't help. Ant expects the setting in an environment variable.

4) Computer programs don't lie. They tell the truth as they see it. Or to be more accurate, the whole notion of lying and telling the truth is meaningless unless the agent is capable of intention. But the point is that if you start to suspect computer programs of trying to deceive you, you are going to have a hard time debugging things.

(OK, you were joking. But many people faced with a troubleshooting problem take a similarly unproductive approach; e.g. assuming that every tricky Java problem is evidence that the compiler / language / runtime is broken. IMO - it is worth reminding people that this kind of thinking can be very unhelpful ....)

Solution 2:

Try:

$ ant -diagnostics | grep java\\.home

if it's not what you expect, then

$ JAVA_HOME=/path/to/jdk ant -diagnostics | grep java\\.home

Solution 3:

I have a server with ant 1.9.1. It needs an environment variable ANT_RESPECT_JAVA_HOME set, or it will flagrantly ignore the JAVA_HOME environment variable. that does not seem to be the case on another server with ant 1.9.6.

So, depending on you version of ant you might need to add

export ANT_RESPECT_JAVA_HOME=true

in addition to

exportJAVA_HOME=/usr/java/jdk1.7.0_05/

Hope that this helps someone as it took me way too long to discover...

Post a Comment for "Ant Flagrantly Ignoring Java_home Environment Variable"