php editor Xinyi introduces you how to try to build a program using an uninstalled JDK version. During development, it is crucial to use the correct JDK version, but sometimes we may need to try using other versions to solve some problems. At this time, we can specify the JDK version to be used by setting environment variables and use command line tools to build our program. In this article, we will explain in detail how to do these operations to help you successfully complete your development tasks. let's start!
Question content
I installed jdk-21 on a windows computer using the oracle installer. But when I tried to build the project I got an error saying gradlew is incompatible so I uninstalled oracle jdk-21 and now I have installed adoptium build and set java_home
using this commandsetx java_home "c:\program files\eclipse adoptium\jdk-21.0.1.12-hotspot"
When I run where java in command prompt, I get:
c:\program files\eclipse adoptium\jdk.21.0.1.12-hotspot\bin\java.exe
However, when I try to build the project, I get an error message stating that the java executable "c:\program files\java\jdk-21\bin\java.exe" cannot be found. My computer seems to be trying to find the version of oracle I uninstalled.
I followed the instructions in this article and set %java_home%\bin
in the system path, but it says the executable cannot be found.
This is the first entry in my environment variable path
c:\program files\eclipse adoptium\jdk-21.0.1.12-hotspot\bin
This is my last article
%JAVA_HOME%\bin
Why does the program want to build with the uninstalled java version (i.e. the oracle version I removed)?
This link shows a screenshot of the java path on my windows machine.
This java spring project is what I'm trying to build.
Solution
Maybe this is related to the gradle caching mechanism. Delete the .gradle/daemon/<version>/registry.bin</version>
file, it should use your JAVA_HOME
environment variable.
Here is the gradle daemon documentation. Maybe this part causes the subsequent error you describe in your comment. You can use gradle <task> --no-daemon</task>
to disable the current build daemon and check if your project will build.
The project you linked to is using Gradle 8.0.1. Running it with Java 21 is not supported, you can see that in https://docs.gradle.org/current/userguide/compatibility.html. Therefore, to build this project unchanged, you must run Gradle with up to Java 19.
Still using the old Java installation even if JAVA_HOME
is set to the new location sounds strange if you actually run Gradle from the command line. If you run it from an IDE, you must check the IDE settings.
Now I can only imagine that in your GRADLE_USER_HOME
(usually .gradle/
in your user home directory) you have a gradle.properties
where you can set the path to your old Java installation.
If this is not the case, the question is, what is the exact output of you trying to run the build, and where exactly is the error coming from. If it's coming from a Gradle wrapper script, you can turn off echo suppression to see what actually happens.
The above is the detailed content of Trying to build the program using a JDK version that is not installed. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools