• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jean Robillard
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 27918
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
A wop bop a lu bop a womp bam boom! Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic