Reputation: 1702
In some groovy script I added this line:
def JAVA_HOME=/usr/java/jre1.7.0_60
because I get error as
groovy: JAVA_HOME not set and cannot find javac to deduce location, please setJAVA_HOME.
But this did not help.
What’s wrong with this line:
def JAVA_HOME=/usr/java/jre1.7.0_60
or maybe need to use export, but don’t know how to do this in groovy?
Upvotes: 2
Views: 2582
Reputation: 84756
Everything is fine with this line but it just defines a variable named JAVA_HOME
. In JVM it's not possible to export user defined environment variables.
But if it was possible the following code would do the trick:
System.getenv().put('JAVA_HOME', 'path_to_java_home')
You need to define environment variable on the OS level.
Upvotes: 3