0

I am trying to run/invoke a java program on a Jenkins slave using Jenkins. I am getting the error Javac is not recognized. But when i invoke the same program from the jenkins slave host directly, the java program perfectly works fine. I tried setting the java home by export $java_home on the shell script itself but it doesn't seem to do any help. Checked the versions of java and all looked okay. Any thoughts/ideas??

chanukhya bachina
  • 171
  • 1
  • 3
  • 16

2 Answers2

0

Effective value PATH variable in that script does not have java. There are many ways to solve it.

Option 1

User absolute path to your java. You already have JAVA_HOME defined. So refer to java as $JAVA_HOME/bin/java ...

Option 2

Variant of above. Add $JAVA_HOME/bin to PATH. Like below

  export PATH=$JAVA_HOME/bin:$PATH

Option 3

Further variation on above. Allow Jenkins to install JDK and set environment variable pointing to installation. Use this environment variable in your script.

Jayan
  • 18,003
  • 15
  • 89
  • 143
  • Thanks for the reply Jayan. Option 1 is not feasible because my java program/app contains references to other java programs/dependencies. Option 2: Already tried and din't help. Option 3 definitely works but can't do it because of space limitations. – chanukhya bachina Dec 03 '15 at 03:10
  • I have settled with Option 3. – chanukhya bachina Dec 03 '15 at 20:18
0

I specified the absolute value of Java path in Environment variables in Node Properties like below

JAVA_HOME

C:\Program Files\Java\jdk-17

And it worked

vinodhraj
  • 177
  • 1
  • 7