Question: Trying to setup jenkins but my builds fails with:

```
$ ant test
Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Build step 'Invoke Ant' marked build as failure

```

If I manually run "ant test" on the machine it works just fine and the JAVA\_HOME is set to the exact same value. Any idea why it fails when jenkins try to run it ? Are there any more environment variabled involved ( I could not see any though ) ?

Answer: 
Set `JAVA_HOME` in your Jenkins system config in Jenkins 2.107.1.

open your jenkins, e.g. <http://192.168.1.12:9090>, then add `/configure` to the url, 
that is `http://192.168.1.12:9090/configure`, then you can find like next:

[![enter image description here](https://i.stack.imgur.com/w5j7A.png)](https://i.stack.imgur.com/w5j7A.png)
For me the options above did not help, solved by creating a link to what's asked:

```
sudo ln -s ${actual_java_location} /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

```

actual\_java\_location can be read by this:

```
 readlink -f $(which java)

```