IntelliJ IDEA + JDK 21 issue with java.util.concurrent package - TimeUnit class not available
Asked Answered
T

1

12

I have an issue when I am trying to use TimeUnit class from java.util.concurrent. It happens with Oracle JDK 21.0.1 (configurations are below) + IntelliJ IDEA 2023.1.5 (Community Edition) - the latest update at the current moment (UPDATE: As I thought in the beginning since I've run update - look a solution below).

Configuration on my computer (get by java -version in console):

java version "21.0.1" 2023-10-17 LTS

Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29)

Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

And I've checked that I set up JDK 21 in IntelliJ Project Structure menu including Project and Modules sections.

On the screenshot below you can see a basic class created for test purposes. Some concurrent package classes are imported fine, but not TimeUnit class for some reason.

The issue screenshot

Meanwhile you can see on the screenshot that app works despite the issue when I run it.

When I am using java 17 in IDE configurations, I don't see the issue.

Could you please help to understand why this issue happens and how to fix it?

One more thing. When I go to "About IntelliJ IDEA" menu, I see the next configuration:

Runtime version: 17.0.7+10-b829.16 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

I am not sure why it says version 17, could it be a reason of the issue?

Trajan answered 26/11, 2023 at 10:34 Comment(2)
Looks like an IntelliJ cache problem. Try removing the out directory and rebuild it again, if that doesn't help try to invalidate the IntelliJ cache and restart.Ovine
Actually, I've tried to invalidate caches and recreated .idea folder, but it didn't help. As I mentioned in the answer, only IntelliJ update to the last version fixed this issue.Trajan
T
5

While searching, I found a solution.

Following the same kind of issue discussed in this topic, I manually updated IntelliJ to version 2023.2.5 one more time, and now the issue is resolved.

It appears that when updating IntelliJ, it may be necessary to perform the update process multiple times consecutively.

Trajan answered 26/11, 2023 at 10:34 Comment(5)
Invalidating caches might be a less drastic solution.Bracteole
Actually, I've tried to invalidate caches and recreated .idea folder, but it didn't help. As I mentioned in the answer, only IntelliJ update to the last version fixed this issue.Trajan
I have the same problem, but unfortunately I cannot update IntelliJ.Possie
@BasilBourque tried your propose. Invalidate caches did not helpTwopenny
Tip: I have had good luck with deleting any copies of IntelliJ that were manually installed, then uso only JetBrains Toolbox for automatic installs and updates of IntelliJ (and any other JetBrains apps).Bracteole

© 2022 - 2025 — McMap. All rights reserved.