Bug 50805 - Can't find resources in source folder that has an output folder
Summary: Can't find resources in source folder that has an output folder
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-28 16:51 EST by Kenneth Corbin CLA
Modified: 2004-02-09 13:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Corbin CLA 2004-01-28 16:51:36 EST
I keep separate source and test class trees in src and test folders 
respectively.   The test classes have to find various resource files that are 
located in the root test folder.  They do this using a class loader getresource
() method which will find the files if they are anywhere on the class path.

This all worked just fine when the classes were compiled to the source 
folders.  But when I tried to compile classes to a separate output folder it 
quit working.   Apparently the output folder is added to the classpath, but 
the original source folder is not.   This would be fine if I could add the 
original source folder as a class folder on the Properties | Java Build Path | 
Libraries tab.  But when I try that it complains that classpath contains a 
duplicate entry and won't accept it.

The JDT either needs to include both the source and output folders in the 
class path, or allow me to manually add the source folder to the class path.
Comment 1 Philipe Mulet CLA 2004-01-28 19:18:01 EST
Source folders are meant to contain sources. You can have them be an output as 
well, as you already know. If you separate their output, then they won't appear 
on the classpath at runtime. This is why the resources in there are copied also 
into the output automatically (except for .java files which are considered as 
sources, thus only generated .class files are necessary at runtime).

If you want to have .java resources available at runtime, then you should store 
these into a class folder. It will be appended to the runtime classpath.

Does this work ? 
Comment 2 Kenneth Corbin CLA 2004-01-29 00:58:40 EST
If the resource files got copied to the output folder everything would be cool.   But this isn't 
happening.   Is there something I am supposed to do to declare them as resources? 
 
It makes sense that the source folder wouldn't automatically be added to the classpath, but I 
should be able to manually add it as a class folder in library tab without it complaining that it is a 
duplicate classpath entry. 
Comment 3 Philipe Mulet CLA 2004-01-29 04:38:30 EST
Well, we don't want the same thing to be made available twice.

First, are these resources Java files or not ?
Comment 4 Kenneth Corbin CLA 2004-01-29 08:37:33 EST
The files in question are not .java files.   They are pretty much all XML files
with a .xml extension.
Comment 5 Kenneth Corbin CLA 2004-02-04 23:31:35 EST
Problem solved.  Eclipse is copying all of the resource files when I ask it to build the project.   My 
problem was that I was trying to run programs without building them, not realizing that it wasn't 
going to go through the build process first.   It found the compiled classes just fine because I had 
built them with an Ant script, but the Ant script put the original source folder on the path rather 
than copy the resources to the class folder.   So test programs ran fine under Ant, but not under 
Eclipse proper. 
Comment 6 Jerome Lanneluc CLA 2004-02-09 13:00:15 EST
Reopening to mark as invalid (no action was taken from the JDT Core team to fix 
this problem)
Comment 7 Jerome Lanneluc CLA 2004-02-09 13:01:30 EST
User error.