This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
6 Replies Last post: Jun 5, 2010 8:20 AM by Serge Merzliakov  
Jeffrey Ellin Newbie 5 posts since
Mar 11, 2010
Currently Being Moderated

Mar 11, 2010 9:11 PM

Intellij can't find classes in same package

I am using Intellij Community and am having a strange issue.

 

If a class depends on a class in the same package the ide can't seem to find it.  The class is highlighted in red.  If I explicitly import it instead (I shouldn't have to for classes in the same package) the red goes away.  Building the project seems to be fine and produce no errors.


Anyone seen this before?

Dmitry Jemerov JetBrains 11,708 posts since
Aug 19, 2002
Currently Being Moderated
Mar 11, 2010 9:29 PM in response to: Jeffrey Ellin
Re: Intellij can't find classes in same package

Hello Jeffrey,

 

Have you tried using File | Invalidate Caches and restarting IntelliJ IDEA?

 

I am using Intellij Community and am having a strange issue.

 

If a class depends on a class in the same package the ide can't seem

to find it.  The class is highlighted in red.  If I explicitly import

it instead (I shouldn't have to for classes in the same package) the

red goes away.  Building the project seems to be fine and produce no

errors.

 

Anyone seen this before?

 

---

Original message URL:

http://www.jetbrains.net/devnet/message/5258389#5258389

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

 

 

 

Serge Merzliakov Newbie 3 posts since
May 24, 2010
Currently Being Moderated
May 24, 2010 3:08 AM in response to: Dmitry Jemerov
Re: Intellij can't find classes in same package

I have the same issue with Intellij 9.0.2 Ultimate, Java 1.6.20 on Apple OS X 10.6.2. I have a project with 6 modules and everything was fine until one of the modules started to require importing classes in same package. I have invalidated cached repeatedly with no success. I have checked the Dependencies configuration for modules that work and the modules that exhibit this behaviour, and there is no difference.

Using an ant script to compile works fine.

Serge Merzliakov Newbie 3 posts since
May 24, 2010
Currently Being Moderated
May 28, 2010 4:27 AM in response to: Dmitry Jemerov
Re: Intellij can't find classes in same package - Solution Found

The issue occurred with one of six modules, so I deleted all but the offending module ('sick' module which cannot find classes in same package) - and the the issue was fixed. I then added the other modules back to the project one-by-one and found the the problem was related to a single module which had a reference to the 'sick' modules source path.

 

I found in another module this entry in .iml file

<orderEntry type="module-library">

      <library>

        <CLASSES>

          <root url="file://$MODULE_DIR$/lib/compile-no-deploy" />

        </CLASSES>

        <JAVADOC />

        <SOURCES>

         <root url="file://$MODULE_DIR$/../SICK_MODULE/src" /> <== this references the the SICK_MODULES source path

        </SOURCES>

        <jarDirectory url="file://$MODULE_DIR$/lib/compile-no-deploy" recursive="false" />

      </library>

    </orderEntry>

 

When I deleted this reference manually, the problem was fixed:

 

<orderEntry type="module-library">

      <library>

        <CLASSES>

          <root url="file://$MODULE_DIR$/lib/compile-no-deploy" />

        </CLASSES>

        <JAVADOC />

        <SOURCES />

        <jarDirectory url="file://$MODULE_DIR$/lib/compile-no-deploy" recursive="false" />

      </library>

    </orderEntry>

Denis Zhdanov JetBrains 777 posts since
Oct 20, 2007
Currently Being Moderated
May 28, 2010 11:06 AM in response to: Serge Merzliakov
Re: Intellij can't find classes in same package - Solution Found

Hi Serge,

 

Great work!

 

Please try to work out steps to reproduce the problem behaviour and submit corresponding ticket with that information to IDEA tracker.

 

Regards, Denis

Serge Merzliakov Newbie 3 posts since
May 24, 2010
Currently Being Moderated
Jun 5, 2010 8:22 AM in response to: Denis Zhdanov
Re: Intellij can't find classes in same package - Solution Found

Denis,

   Raised incident IDEA-55557. The issue can be summarized as attaching the jar file source fin 'B' module to a dependency causes the "cannot find classes in same package issue" in the module 'A' whose source is referenced.

 

So:

1. module B uses module A jar file (both modules in same project)

2. Open module B dependencies dialog, attach sources to module A source dir

3. open module A in IDE and open a class in any package

4. note that other classes in same package are unresolved and shown as such

 

Serge

More Like This

  • Retrieving data ...