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??
Effective value PATH variable in that script does not have java. There are many ways to solve it.
User absolute path to your java. You already have JAVA_HOME defined. So refer to java as $JAVA_HOME/bin/java ...
Variant of above. Add $JAVA_HOME/bin to PATH. Like below
export PATH=$JAVA_HOME/bin:$PATH
Further variation on above. Allow Jenkins to install JDK and set environment variable pointing to installation. Use this environment variable in your script.