You can not do this on macOS (the OP’s OS) without some form of jiggery-pokery, due to the restricted access of certain file system folders that Apple imposes. I seem to recall someone posting a link on here to a tool that enabled a user to install multiple different JDKs in their home folder, but that would require a bit of searching, and I haven’t tried it myself, as copying the JDKs to relevant system folder isn’t really particularly difficult, once you know how.
On my macOS system, I have the following JDKs installed:
/usr/libexec/java_home -V
Matching Java Virtual Machines (10):
22.0.1 (arm64) “Eclipse Adoptium” - “OpenJDK 22.0.1” /Library/Java/JavaVirtualMachines/temurin-22.jdk/Contents/Home
20.0.1 (arm64) “Oracle Corporation” - “OpenJDK 20.0.1” /Library/Java/JavaVirtualMachines/jdk-20.0.1.jdk/Contents/Home
18.0.1 (arm64) “Eclipse Adoptium” - “OpenJDK 18.0.1” /Library/Java/JavaVirtualMachines/temurin-18.jdk/Contents/Home
17 (arm64) “Azul Systems, Inc.” - “Zulu 17.0.63-ea” /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
17 (arm64) “Oracle Corporation” - “Java SE 17” /Library/Java/JavaVirtualMachines/jdk-17_aarch64.jdk/Contents/Home
17 (x86_64) “Oracle Corporation” - “Java SE 17” /Library/Java/JavaVirtualMachines/jdk-17_x64.jdk/Contents/Home
16.0.2+7 (arm64) “BellSoft” - “BellSoft Liberica JDK 16.0.2+7” /Library/Java/JavaVirtualMachines/liberica-jdk-16-full.jdk/Contents/Home
15 (x86_64) “Oracle Corporation” - “OpenJDK 15” /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
14.0.2 (x86_64) “Oracle Corporation” - “OpenJDK 14.0.2” /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
12.0.2 (x86_64) “Oracle Corporation” - “OpenJDK 12.0.2” /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/temurin-22.jdk/Contents/Home
The latest one (22.0.1 (arm64) “Eclipse Adoptium” - “OpenJDK 22.0.1”, is automatically recognized and selectable under LO Preferences > Advanced
with Version: 7.6.4.1 (AARCH64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Mac OS X 14.4.1; UI render: Skia/Raster; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded