Replies: 3 comments 2 replies
-
|
Sorry, it looks like I was confused about the reason for failure. The "Node.js" thing was just an annoying warning. Why is that happening? |
Beta Was this translation helpful? Give feedback.
-
|
Hi Fran! You are exactly right about the Node.js warning and the temurin distribution. To answer your final question about why the build job is returning Java 17 instead of Java 21: for the Java version issue the problem is that in GitHub Actions every job runs on a completely separate isolated virtual machine. When you set up Java 21 in your setup job it doesn't carry over to the build job. The build job spins up a brand new Ubuntu environment which happens to have Java 17 installed by default. So when you set up Java 21 in the setup job, it only installed it on that specific machine. When the build job started GitHub spun up a brand new Ubuntu runner which defaults to Java 17. To fix this, you need to run the setup-java step inside the actual build job where you plan to compile your code. Here is how you can combine them: jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Check Java version
run: javac --version # This will now output 21!If your workflow requires setup and build to be separate jobs you will just need to repeat that exact same setup-java step at the beginning of the build job as well. Hope this clears things up! Let me know if it gets you unblocked and if it does, I'd appreciate it if you could mark this as the answer. |
Beta Was this translation helpful? Give feedback.
-
|
You are seeing two separate things here. First, Second, the Java 17 result in your For the Node.js warning, that is about the action runtime, not your Java version. GitHub’s setup-java repository currently shows So the fix is: jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
- run: javac --versionIf you want one place to manage the Java setup, a composite action is fine, but it still has to be invoked in every job that needs Java because jobs do not share the same runner environment. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
💬 Feature/Topic Area
Actions Checkout
Discussion Details
I created my first action containing multiple jobs. The first being a "setup" job that others depend upon. That "setup" job is failing with a complaint about Node.js version when I am not specifying anything that has to do with JS. The relevant section of the action is:
The action looks like it is running as expected, but the "setup" job fails with the following message:
Node.js 20 is deprecated. The following actions target Node.js 20 but are being forced to run on Node.js 24: actions/setup-java@v4. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/Although the provided URL has an explanation of the "20 vs. 24" issue, I do not see the actual relevance to this action since nothing is directing it to do anything that is not default.
The relevant steps were originally copied from the "Java using Ant" template.
I changed the "checkout@v4" to request v6 after researching this same error on the first run.
My "on" statement uses a "workflow_dispatch" and that all seems to be working fine.
You can see some of the other things that I tried without success in the comments.
Beta Was this translation helpful? Give feedback.
All reactions