aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse does not like it if a package exists in parallel directory structure.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse does not like it if a package exists in parallel directory structure.. " Watch "Eclipse does not like it if a package exists in parallel directory structure.. " New topic
Author

Eclipse does not like it if a package exists in parallel directory structure..

Jean Robillard
Greenhorn

Joined: Apr 07, 2008
Posts: 17
Hi, I have the following directory structure w/ JUNIT (which is not really relevant though)

src (directory)
src/com
src/com/xyz
src/com/xyz/SomeClass.java

test (directory)
test/com
test/com/xyz
test/com/xyz/SomeClassTest.java

Note: src, test are under the same project's "Java Resources" node in Eclipse.


Unfortunately, within Eclipse, SomeClassTest cannot test SomeClass, because it cannot "see" SomeClass even though they are supposed to be in the same package com.xyz. Eclipse would simply complain that SomeClass cannot be resolved, with an "X" icon at the offending line that references SomeClass within SomeClassTest.

Can I resolve this issue in Eclipse, or do I have to do this manually (e.g. via ANT) by copying these files into the same directory before compiling them together (which means, I wouldn't be able to use Eclipse anymore). Thanks....
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

Are both "src" and "test" marked as Java source files within Eclipse?

Did you by any chance get this directory structure form a Maven archetype? If so, running "maven eclipse:eclipse" will create an Eclipse project with the proper source folder already marked.


JBoss In Action
Jean Robillard
Greenhorn

Joined: Apr 07, 2008
Posts: 17
No I am not using Maven. But it's resolved now. For some reason, I must go to Project->Properties->Source tab->Add Folder... menu to add a new source folder. Instead, I had manually created a folder called test from Windows explorer. Even though Eclipse detected this directory and displayed it under "Java Resources" in its Project Explorer, it didn't quite do it right and exhibited the problem I originally described, even though the Project properties correctly displayed it as a source folder. Weird.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Jean Robillard wrote:No I am not using Maven. But it's resolved now. For some reason, I must go to Project->Properties->Source tab->Add Folder... menu to add a new source folder. Instead, I had manually created a folder called test from Windows explorer. Even though Eclipse detected this directory and displayed it under "Java Resources" in its Project Explorer, it didn't quite do it right and exhibited the problem I originally described, even though the Project properties correctly displayed it as a source folder. Weird.


There's folders and then there's SOURCE folders. If you'll notice in the Navigator view, the two have slightly different icons. Only SOURCE folders are processed by the Eclipse compiler.

Once compiled, the output classes are written to a binary folder. By default, only one such folder exists per project, but you can make a separate binary folder for any or all of the source folders - for example, a test/classes directory.

The binary folder(s) are referenced as part of the classpath for both compiling and testing.


Customer surveys are for companies who didn't pay proper attention to begin with.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
Tim Holloway wrote:

There's folders and then there's SOURCE folders. If you'll notice in the Navigator view, the two have slightly different icons. Only SOURCE folders are processed by the Eclipse compiler.



old post helped me out. thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse does not like it if a package exists in parallel directory structure..