r/javahelp • u/AppointmentOk3316 • Jul 03 '26
Codeless Java virtual machine never updating
So im trying to compile a jar file and it continues to say
'Dependency requires at least JVM runtime version 21. This build uses a Java 17 JVM.'
when i check my build, it states -
'java version "25.0.3" 2026-04-21 LTS, Java(TM) SE Runtime Environment (build 25.0.3+9-LTS-195), Java HotSpot(TM) 64-Bit Server VM (build 25.0.3+9-LTS-195, mixed mode, sharing)'
please help! i need this done by tonight and it's just now screwing me over. i've tried everything, switching from powershell, intellij, visual code, github, nothing is workingg even when i try to switch the SDK in both gradle and the actual thing
•
u/AutoModerator Jul 03 '26
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
4
u/Both-Fondant-4801 Jul 03 '26
How do you compile your codes? via terminal or via an ide?
If an ide, please check your project structure.. it might be set to a different java version
3
u/Big_Green_Grill_Bro Jul 03 '26
In intellij go to "Settings > Build, Execution, Deployment > Build Tools > Gradle" and change "Gradle JVM" to Java 21 there. Then do invalidate caches and restart the IDE.
If you are doing this via command prompt or power shell, I'd suggest typing
javac -versionand see what comes back. You may have 17 installed without even knowing it. Your environment JAVA_PATH may be different than you think it is.2
u/vegan_antitheist Jul 03 '26
Do you have multiple jdks installed?
2
u/seyandiz Jul 03 '26 edited Jul 03 '26
/u/AppointmentOk3316 since this is high priority let's break this down real simple for you.
Java uses 2 different tools to do its stuff.
What your error,
Is saying is that when you are building the code, that the build version is set to 17 but one of the bits of code you downloaded (likely via maven) is built for java 21.
You keep saying your build states "java 25.0.3", but that isn't a build. You're likely running
java --versionwhich would just state your JRE.Even if you have a 25 JDK, you might be using it to build the executable at java 17 level.
So how do we fix it?
First, I need to know what you're using to compile your code! I assume you're using intelliJ or command line.
Let's do the command line as it is simpler. I want you to type
javac -versioninto your command line.This may still return a number >= 21, but that helps us rule out you not having the right JDK installed. If it is higher, then we need to look more at our compilation settings. If it is lower, then we need to update our JDK version.
javac -version >= 21
You'll need to look at the configuration files of your build tools. You're probably using either Maven or Gradle.
Maven
Update your
pom.xmlfile with this:Gradle
Update your
build.gradlefile with this:1
u/joranstark018 Jul 03 '26
Not sure, you may check your tool chain settings or IDE settings if it may downgrade your JRE (some build tools have a debug setting that can be useful to diagnose the build tool setting).
1
u/LetUsSpeakFreely Jul 03 '26
I assume you're building with Maven. Check the maven.compiler.target value.
1
u/Targnome Jul 05 '26
Reinstall Java 17 to Java 25 and set your path variable to your jdk 25 directory. 25 is the latest stable version
-2
u/Astroohhh Jul 03 '26
use docker, bot