I am trying to run an application that needs Java as a prerequisite on a github actions runner. My yaml script is like:
steps:
.
.
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '21'
.
.
- name: Step that needs Java
uses: ...
with:
...
The Java setup goes fine, but the step that needs Java fails with an error saying
ERROR: The JAVA_HOME environment variable is not defined correctly. JAVA_HOME is set to /opt/hostedtoolcache/Java_Adopt_jdk/21.0.4-7.0.LTS/x64 and it does not exist.
The correct path is /opt/hostedtoolcache/Java_Adopt_jdk/21.0.4-7.0.LTS/x64/bin
What do I do to append /bin
to the end of JAVA_HOME
?
2
Answers
Your setup is correct. JAVA_HOME is also correct. If you run just the setup action
actions/setup-java@v2
, java is setup correctly and $JAVA_HOME/bin is in the PATH.The issue is most likely with the steps that follow java setup in your workflow.
This workflow proves it:
The output of the "Show java" step is like this:
similar issue I am facing on below workflow:
Please do suggest how to fix this issue ?