Intellij will not recognize my JDK directory, claims it is a JAR

已回答

I have JDKs on my computer at c:\Program Files\java\jdk17 and c:\Program Files\java\jdk21. I have IntelliJ IDEA 2025.1.3 (Community Edition). When I open Project Structure | Platform Settings | SDKs and try to add these, I can successfully add jdk21, but when I try to add jdk17, I get the message “The selected directory points to a JRE, not a JDK.” What is causing this? The directory is definitely a JDK, it contains jmods and the bin folder has javac, jar, javadoc, jshell.

C:\Program Files\Java\jdk17>tree /f
Folder PATH listing for volume OSDisk
Volume serial number is 58B0-2F36
C:.
│   LICENSE
│   README
│   release

├───bin
│   │   api-ms-win-core-console-l1-1-0.dll
│   │   api-ms-win-core-console-l1-2-0.dll
│   │   api-ms-win-core-datetime-l1-1-0.dll
│   │   api-ms-win-core-debug-l1-1-0.dll
│   │   api-ms-win-core-errorhandling-l1-1-0.dll
│   │   api-ms-win-core-fibers-l1-1-0.dll
│   │   api-ms-win-core-file-l1-1-0.dll
│   │   api-ms-win-core-file-l1-2-0.dll
│   │   api-ms-win-core-file-l2-1-0.dll
│   │   api-ms-win-core-handle-l1-1-0.dll
│   │   api-ms-win-core-heap-l1-1-0.dll
│   │   api-ms-win-core-interlocked-l1-1-0.dll
│   │   api-ms-win-core-libraryloader-l1-1-0.dll
│   │   api-ms-win-core-localization-l1-2-0.dll
│   │   api-ms-win-core-memory-l1-1-0.dll
│   │   api-ms-win-core-namedpipe-l1-1-0.dll
│   │   api-ms-win-core-processenvironment-l1-1-0.dll
│   │   api-ms-win-core-processthreads-l1-1-0.dll
│   │   api-ms-win-core-processthreads-l1-1-1.dll
│   │   api-ms-win-core-profile-l1-1-0.dll
│   │   api-ms-win-core-rtlsupport-l1-1-0.dll
│   │   api-ms-win-core-string-l1-1-0.dll
│   │   api-ms-win-core-synch-l1-1-0.dll
│   │   api-ms-win-core-synch-l1-2-0.dll
│   │   api-ms-win-core-sysinfo-l1-1-0.dll
│   │   api-ms-win-core-timezone-l1-1-0.dll
│   │   api-ms-win-core-util-l1-1-0.dll
│   │   api-ms-win-crt-conio-l1-1-0.dll
│   │   api-ms-win-crt-convert-l1-1-0.dll
│   │   api-ms-win-crt-environment-l1-1-0.dll
│   │   api-ms-win-crt-filesystem-l1-1-0.dll
│   │   api-ms-win-crt-heap-l1-1-0.dll
│   │   api-ms-win-crt-locale-l1-1-0.dll
│   │   api-ms-win-crt-math-l1-1-0.dll
│   │   api-ms-win-crt-multibyte-l1-1-0.dll
│   │   api-ms-win-crt-private-l1-1-0.dll
│   │   api-ms-win-crt-process-l1-1-0.dll
│   │   api-ms-win-crt-runtime-l1-1-0.dll
│   │   api-ms-win-crt-stdio-l1-1-0.dll
│   │   api-ms-win-crt-string-l1-1-0.dll
│   │   api-ms-win-crt-time-l1-1-0.dll
│   │   api-ms-win-crt-utility-l1-1-0.dll
│   │   attach.dll
│   │   awt.dll
│   │   dt_shmem.dll
│   │   dt_socket.dll
│   │   fontmanager.dll
│   │   freetype.dll
│   │   instrument.dll
│   │   j2gss.dll
│   │   j2pcsc.dll
│   │   j2pkcs11.dll
│   │   jaas.dll
│   │   jabswitch.exe
│   │   jaccessinspector.exe
│   │   jaccesswalker.exe
│   │   jar.exe
│   │   jarsigner.exe
│   │   java.dll
│   │   java.exe
│   │   javaaccessbridge.dll
│   │   javac.exe
│   │   javadoc.exe
│   │   javajpeg.dll
│   │   javap.exe
│   │   javaw.exe
│   │   jawt.dll
│   │   jcmd.exe
│   │   jconsole.exe
│   │   jdb.exe
│   │   jdeprscan.exe
│   │   jdeps.exe
│   │   jdwp.dll
│   │   jfr.exe
│   │   jhsdb.exe
│   │   jimage.dll
│   │   jimage.exe
│   │   jinfo.exe
│   │   jli.dll
│   │   jlink.exe
│   │   jmap.exe
│   │   jmod.exe
│   │   jpackage.dll
│   │   jpackage.exe
│   │   jps.exe
│   │   jrunscript.exe
│   │   jshell.exe
│   │   jsound.dll
│   │   jstack.exe
│   │   jstat.exe
│   │   jstatd.exe
│   │   jsvml.dll
│   │   keytool.exe
│   │   kinit.exe
│   │   klist.exe
│   │   ktab.exe
│   │   lcms.dll
│   │   le.dll
│   │   management.dll
│   │   management_agent.dll
│   │   management_ext.dll
│   │   mlib_image.dll
│   │   msvcp140.dll
│   │   net.dll
│   │   nio.dll
│   │   prefs.dll
│   │   rmi.dll
│   │   rmiregistry.exe
│   │   saproc.dll
│   │   serialver.exe
│   │   splashscreen.dll
│   │   sspi_bridge.dll
│   │   sunmscapi.dll
│   │   ucrtbase.dll
│   │   vcruntime140.dll
│   │   vcruntime140_1.dll
│   │   verify.dll
│   │   w2k_lsa_auth.dll
│   │   windowsaccessbridge-64.dll
│   │   WinFallbackLookup.dll
│   │   zip.dll
│   │
│   └───server
│           classes.jsa
│           classes_nocoops.jsa
│           jvm.dll

├───conf
│   │   logging.properties
│   │   net.properties
│   │   sound.properties
│   │
│   ├───management
│   │       jmxremote.access
│   │       jmxremote.password.template
│   │       management.properties
│   │
│   └───security
│       │   java.policy
│       │   java.security
│       │
│       └───policy
│           │   README.txt
│           │
│           ├───limited
│           │       default_local.policy
│           │       default_US_export.policy
│           │       exempt_local.policy
│           │
│           └───unlimited
│                   default_local.policy
│                   default_US_export.policy

├───include
│   │   classfile_constants.h
│   │   jawt.h
│   │   jdwpTransport.h
│   │   jni.h
│   │   jvmti.h
│   │   jvmticmlr.h
│   │
│   └───win32
│       │   jawt_md.h
│       │   jni_md.h
│       │
│       └───bridge
│               AccessBridgeCallbacks.h
│               AccessBridgeCalls.h
│               AccessBridgePackages.h

├───jmods
│       java.base.jmod
│       java.compiler.jmod
│       java.datatransfer.jmod
│       java.desktop.jmod
│       java.instrument.jmod
│       java.logging.jmod
│       java.management.jmod
│       java.management.rmi.jmod
│       java.naming.jmod
│       java.net.http.jmod
│       java.prefs.jmod
│       java.rmi.jmod
│       java.scripting.jmod
│       java.se.jmod
│       java.security.jgss.jmod
│       java.security.sasl.jmod
│       java.smartcardio.jmod
│       java.sql.jmod
│       java.sql.rowset.jmod
│       java.transaction.xa.jmod
│       java.xml.crypto.jmod
│       java.xml.jmod
│       jdk.accessibility.jmod
│       jdk.attach.jmod
│       jdk.charsets.jmod
│       jdk.compiler.jmod
│       jdk.crypto.cryptoki.jmod
│       jdk.crypto.ec.jmod
│       jdk.crypto.mscapi.jmod
│       jdk.dynalink.jmod
│       jdk.editpad.jmod
│       jdk.hotspot.agent.jmod
│       jdk.httpserver.jmod
│       jdk.incubator.foreign.jmod
│       jdk.incubator.vector.jmod
│       jdk.internal.ed.jmod
│       jdk.internal.jvmstat.jmod
│       jdk.internal.le.jmod
│       jdk.internal.opt.jmod
│       jdk.internal.vm.ci.jmod
│       jdk.internal.vm.compiler.jmod
│       jdk.internal.vm.compiler.management.jmod
│       jdk.jartool.jmod
│       jdk.javadoc.jmod
│       jdk.jcmd.jmod
│       jdk.jconsole.jmod
│       jdk.jdeps.jmod
│       jdk.jdi.jmod
│       jdk.jdwp.agent.jmod
│       jdk.jfr.jmod
│       jdk.jlink.jmod
│       jdk.jpackage.jmod
│       jdk.jshell.jmod
│       jdk.jsobject.jmod
│       jdk.jstatd.jmod
│       jdk.localedata.jmod
│       jdk.management.agent.jmod
│       jdk.management.jfr.jmod
│       jdk.management.jmod
│       jdk.naming.dns.jmod
│       jdk.naming.rmi.jmod
│       jdk.net.jmod
│       jdk.nio.mapmode.jmod
│       jdk.random.jmod
│       jdk.sctp.jmod
│       jdk.security.auth.jmod
│       jdk.security.jgss.jmod
│       jdk.unsupported.desktop.jmod
│       jdk.unsupported.jmod
│       jdk.xml.dom.jmod
│       jdk.zipfs.jmod

├───legal
│   ├───java.base
│   │       aes.md
│   │       asm.md
│   │       c-libutl.md
│   │       cldr.md
│   │       COPYRIGHT
│   │       icu.md
│   │       LICENSE
│   │       public_suffix.md
│   │       siphash.md
│   │       unicode.md
│   │       wepoll.md
│   │       zlib.md
│   │
│   ├───java.compiler
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.datatransfer
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.desktop
│   │       colorimaging.md
│   │       COPYRIGHT
│   │       freetype.md
│   │       giflib.md
│   │       harfbuzz.md
│   │       jpeg.md
│   │       lcms.md
│   │       libpng.md
│   │       LICENSE
│   │       mesa3d.md
│   │
│   ├───java.instrument
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.logging
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.management
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.management.rmi
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.naming
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.net.http
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.prefs
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.rmi
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.scripting
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.se
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.security.jgss
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.security.sasl
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.smartcardio
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.sql
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.sql.rowset
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.transaction.xa
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───java.xml
│   │       bcel.md
│   │       COPYRIGHT
│   │       dom.md
│   │       jcup.md
│   │       LICENSE
│   │       xalan.md
│   │       xerces.md
│   │
│   ├───java.xml.crypto
│   │       COPYRIGHT
│   │       LICENSE
│   │       santuario.md
│   │
│   ├───jdk.accessibility
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.attach
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.charsets
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.compiler
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.crypto.cryptoki
│   │       COPYRIGHT
│   │       LICENSE
│   │       pkcs11cryptotoken.md
│   │       pkcs11wrapper.md
│   │
│   ├───jdk.crypto.ec
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.crypto.mscapi
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.dynalink
│   │       COPYRIGHT
│   │       dynalink.md
│   │       LICENSE
│   │
│   ├───jdk.editpad
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.hotspot.agent
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.httpserver
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.incubator.foreign
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.incubator.vector
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.internal.ed
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.internal.jvmstat
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.internal.le
│   │       COPYRIGHT
│   │       jline.md
│   │       LICENSE
│   │
│   ├───jdk.internal.opt
│   │       COPYRIGHT
│   │       jopt-simple.md
│   │       LICENSE
│   │
│   ├───jdk.internal.vm.ci
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.internal.vm.compiler
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.internal.vm.compiler.management
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jartool
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.javadoc
│   │       COPYRIGHT
│   │       jquery.md
│   │       jqueryUI.md
│   │       LICENSE
│   │
│   ├───jdk.jcmd
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jconsole
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jdeps
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jdi
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jdwp.agent
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jfr
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jlink
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jpackage
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jshell
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jsobject
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.jstatd
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.localedata
│   │       cldr.md
│   │       COPYRIGHT
│   │       LICENSE
│   │       thaidict.md
│   │
│   ├───jdk.management
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.management.agent
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.management.jfr
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.naming.dns
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.naming.rmi
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.net
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.nio.mapmode
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.random
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.sctp
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.security.auth
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.security.jgss
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.unsupported
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.unsupported.desktop
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   ├───jdk.xml.dom
│   │       COPYRIGHT
│   │       LICENSE
│   │
│   └───jdk.zipfs
│           COPYRIGHT
│           LICENSE

├───lib
│   │   classlist
│   │   ct.sym
│   │   fontconfig.bfc
│   │   fontconfig.properties.src
│   │   jawt.lib
│   │   jvm.cfg
│   │   jvm.lib
│   │   modules
│   │   psfont.properties.ja
│   │   psfontj2d.properties
│   │   src.zip
│   │   tzdb.dat
│   │   tzmappings
│   │
│   ├───jfr
│   │       default.jfc
│   │       profile.jfc
│   │
│   └───security
│           blocked.certs
│           cacerts
│           default.policy
│           public_suffix_list.dat

├───PackageCache
│       inventory.ps1
│       uninstall.ps1

└───uninstaller
       unins000.dat
       unins000.exe
 

C:\Program Files\Java\jdk17>bin\java --version
java 17.0.16 2025-07-15 LTS
Java(TM) SE Runtime Environment (build 17.0.16+12-LTS-247)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.16+12-LTS-247, mixed mode, sharing)

0

I was able to fix the problem by deleting jdk17 and re-installing. Not sure what the problem was.

0

Thanks for the update. If you face it again, please compress the whole folder then upload it to https://uploads.jetbrains.com/ and paste the upload id here. Then I'll try to reproduce it.

0

请先登录再写评论。