Tag Archives: java 17

How to Solve IntelliJ IDEA Error: Cannot determine path to ‘tools.jar‘ library for 17 (C:\Program Files\Java\jd…

this month, Java 17 was finally released. This is another lts version after Java 11. I decided to try Java 17. Sure enough, something unexpected happened: when I used java 17 to run a project that used to run normally, IntelliJ idea reported the following error:

Operating environment when the author reports an error:

IntelliJ IDEA 2020.1.2 (Ultimate Edition)

JDK 17

Error:Cannot determine path to 'tools.jar' library for 17 (C:\Program Files\Java\jdk-17)

then, as before. The author tried to run a very simple demo project, and sure enough, the same error occurred again. The environment in which the project used to operate normally is:

The environment in which the project previously operated normally:

IntelliJ IDEA 2020.1.2 (Ultimate Edition)

JDK 11

the author has repeatedly installed multiple versions of Java on different operating systems, and is very familiar with this error report. This error indicates that the current IntelliJ idea cannot parse this version of JDK, so it tries to parse tools. Jar from its built-in environment variable classpath , but it still fails, so it throws the above error message.

this can be confirmed. It can be clearly seen in the project structure in the figure below that the author’s IntelliJ idea 2020.1.2 (Ultimate Edition) supports parsing JDK 14 at most, so there is nothing to do with Java 17.

Method 1

it’s easy to do when you know the reason. One way is to reduce the JDK version so that the current IntelliJ idea can recognize it.

The environment in which the project previously operated normally:

IntelliJ IDEA 2020.1.2 (Ultimate Edition)

JDK 11

install the lower version of JDK first, and then set it in project structure in IntelliJ idea. See the figure below. But I usually don’t like it.

Method 2

another way is to improve the version of IntelliJ idea. Therefore, the author specially downloaded and installed the latest IntelliJ idea 2021.2.2 (Ultimate Edition) . Unexpectedly and reasonably, the author encountered many holes when installing the latest IntelliJ idea. I have always wanted to stand on the shoulders of giants, but in fact, they are always used as stepping stones by giants. For the problem that IntelliJ idea cannot be opened after installation, see another blog of the author:

solve the problem that the interface disappears after IntelliJ idea is installed, and the interface does not move after it is opened again.

when I first downloaded it, I was worried that it could not parse Java 17, but now it seems that this worry is superfluous.

The environment in which the project operates normally:

IntelliJ IDEA 2021.2.2 (Ultimate Edition)

JDK 17

after upgrading IntelliJ idea, configure project structure as follows.