JRE classes like java.lang.String cannot be resolved.

Dear All,

I have imported a maven project from a svn repository into the Intellij Idea 9.0 community edition. The main project has a number of sub-projects. The projects were imported as modules in IntelliJ. When I rebuild the top project using Build -->Rebuild project I see errors like java.lang.Object cannot be resolved. Similarly other JRE/ java SDK classes cannot be resolved. I have configured a SDK for the module project. This SDK has the src files as well as the compiled JRE class files for Object, String etc.

My question is .. Why is IntelliJ not finding these class files inspite of the SDK being listed as a dependency for the module.
All input is appreciated, What am I missing ?

--Thanks,
Rohit Kelapure

1 comment
Comment actions Permalink

Hello Rohit,

Welcome to the IntelliJ IDEA community.

Sounds like there is a misconfiguration in the project setup somewhere with the JDK such that IntelliJ IDEA is not finding the SDK.

First, verify you have a JDK set up:
1) Open up the "Project Structure" dialog (ctrl+alt+shift+S).
2) On the far left, select "SDKs" under the "Platform Settings" section.
3) In the middle pane will be a list of all the SDKs you have configured. If you have none, or do not have the one you need, click the '+" icon at the top, or type Alt+Insert. Select JSDK and add a Java SDK. Adding the source as well as the classes will allow IDEA to provide more inline help such as JavaDocs and stepping into the code during debugging. Give the JDK a name. In the rest of the information below, I'll assume the name is "JDK 1.6". It sounds like you may already have this, but I just want to be sure you have added your JDK as a SDK and not as a standard library.
4) Be sure to hit apply so you don't lose your changes.

Second, make sure your project has a JDK configured.
1) In the same Project Structure" dialog (ctrl+alt+shift+S), in the far left pane, select "Project" within the "Project Settings" section.
2) On the right, make sure where it says "Project SDK", a Java SDK, such as the "JDK 1.6" we created above is listed. Note that you could also create a new JDK SDK definition here, by clicking the "New" button, rather than where we did above.
3) Set the "Project language level" as appropriate.
4) Be sure to hit apply so you don't lose your changes.

Third, make sure you module(s) have a JDK listed.
1) In the same Project Structure" dialog (ctrl+alt+shift+S), in the far left pane, select "Modules" in the "Project Settings" section.
2) Select each module you have in the have created in the middle pane, and then select the "Dependencies" tab in the far right pane.
3) Make sure the JDK is specified in the "module SDK". Typically you can leave this set as "Project SDK" unless your module needs a different SDK. Just to verify one comment you made... you said have the SDK "listed as a dependency for the module." I just want to make sure you do not mean it is listed in the list of dependencies on the "Dependencies" tab. That would make it a standard library. It should be specified in the "Module SDK".

Save your changes and you should be all set.

2

Please sign in to leave a comment.