Compiling the project under Jenkins reported an error: java.io.IOException: Cannot run program "java" (in directory "directory"): error=2, No such file or directory, the situation I encountered was due to the environment The variable setting is caused by the fact that Jenkins is not restarted after the server restarts. Need to add a script to Jenkins:
pwd
source ~/.bash_profile
source /etc/profile
The problem is solved after adding the script!