-2

Whenever I open a Java project by opening the pom file as a project, it doesn't automatically load the jdk for the project workspace. It shows me a message at the top that says "Module JDK is not defined" with a button "Setup SDK". I then manually select the JDK distribution and move along.

Is there a way I can eliminate this manual step and have IntelliJ somehow read which JDK it should use from the pom file?

I'm using IntelliJ IDEA 2022.2.3

Sankalp
  • 1,182
  • 2
  • 17
  • 22
  • What IDE version do you use? Do you already have SDK of the version specified in the pom configured in the IDE? Do you expect IDE to download and setup the SDK for you when you import pom.xml? – CrazyCoder Jun 29 '23 at 18:31
  • @CrazyCoder I do not expect the IDE to download the sdk for me. I have the jdk installed. When I run the application from terminal, it gets the jdk version from the $JAVA_HOME variable. So I don't have to specify the jdk each time I build an application. I was hoping if IntelliJ could also determine the jdk version somehow. – Sankalp Jun 29 '23 at 18:52
  • You should setup SDKs only once in the IDE, and it will be configured automatically if it's suitable for your Maven project once you import it. Make sure you run the latest IntelliJ IDEA version and actually have the matching JDK version configured per https://www.jetbrains.com/help/idea/sdk.html. – CrazyCoder Jun 29 '23 at 18:54

1 Answers1

0

I would suggest to check this options:

Also it might be that some projects are cached, I mean if each time when you open the same project and idea suggests to choose SDK. In this case I can suggest to remove .idea folder and reopen the project.

As well you can consider invalidate cache option (https://www.jetbrains.com/help/idea/invalidate-caches.html)

ikhot
  • 1
  • 2