I have sdkman installed on my PC laptop. I work on two separate projects, where P1 uses Java 11 and P2 uses Java 8. If I am working on P1, but something comes up and I need to work on P2, I will open up P2 using my ide (IntelliJ IDEA). Since P2 uses Java 8, I will open a terminal and use sdkman to change my pc to use Java 8. However, when I attempt this, I get 2 error messages:
user1@ bin $ sdk default java 8.322.06.2-amzn
rm: cannot remove '/c/Users/user1/.sdkman/candidates/java/current/lib/jrt-fs.jar':
Device or resource busy
ln: failed to create symbolic link
'/c/Users/user1/.sdkman/candidates/java/current/8.322.06.2-amzn': No such file or
directory
When I look in the "current/" directory, instead of it being populated with the Java 8 JDK, it looks like "lib/jrt-fs.jar" (left over from the previous Java 11 JDK content) has not been deleted, and is in fact still residing in "current/". If I attempt to delete "lib/" via the file system, it tells me that the folder cannot be deleted, as a program is using it. I think there is a file handle not released by the ide, because when I close the ide, I can delete the folder, and I can use sdkman to populate the "current/" folder again.
Question: Is there a way to release the ide file handle on contents in the "current/" folder, without closing the ide?
Caveat: When I googled "Device or resource busy" I saw mentioned that I could use the umount command somehow, but I am not sure if this is a false trail or if I just need more information: here
Note: I am using the Community Edition of IntelliJ IDEA, version 2022.3.2
Edit: Here is a snapshot of the Project Settings that shows picking the JDK from the file system.


Inside IntelliJ versus outside IntelliJ
Unfortunately, configuring which JDK to run your app within IntelliJ is complicated and confusing, requiring you to go spelunking through various buried panels.
These panels include some for the JDK, and some for the language level (which version of Java to target):
There may be others I don't recall at the moment. Search Stack Overflow to learn more.
If you are building a Web app in IntelliJ Ultimate edition, and running that app from within IntelliJ via an external application server such as Tomcat, Jetty, Glassfish, OpenLiberty, etc., then you need to also specify in another IntelliJ panel which JDK should be used to launch that app server.
If using Maven or Gradle, you need to specify language level there too.