|
Re: Source folder vs Folder [message #520475 is a reply to message #520439] |
Fri, 12 March 2010 09:38 |
|
On 3/12/2010 4:52 AM, albertkao wrote:
> What is the difference between "Source folder" and "Folder"?
>
> I had read "Java development user guide > Getting Started > Project
> configuration tutorial "
> http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .jdt.doc.user/gettingStarted/qs-OrganizingSources.htm
> but want to know more.
I think what you're referring to is the distinction between a mere
folder in the filesystem (and also in the Eclipse project) and a folder
(in the filesystem and in the Eclipse project) that ALSO contains
sources, like *.java, that Eclipse is supposed to build into the project.
Defining a folder full of source code to be a Source Folder is something
that can happen in Build Path. However, if you're creating a new
project, you shouldn't have to do this because the new project Wizard
(whether creating a Java Project, Dynamic Web Project, etc.) will create
the top-level src folder as a Source Folder. If later you add additional
folders, such as test, and put, say, JUnit test code underneath it,
you'll need to use Build Path to add it as a Source Folder.
Right-click the folder, choose Build Path, then Use as Source Folder.
Hope this helps,
Russ Bateman
|
|
|
|
Re: Source folder vs Folder [message #520670 is a reply to message #520638] |
Sat, 13 March 2010 22:26 |
|
On 3/13/2010 8:58 AM, albertkao wrote:
> Thank you, you answer my question very well.
> Is Folder always underneath a Source Folder?
> Can a Source Folder underneath a Folder?
> e.g.
> Source Folder/Source Folder/Folder is ok but
> Source Folder/Folder/Source Folder is invalid in Eclipse.
'Source Folder' is a Folder that is specially marked for the Eclipse
project. 'Folder' is just a folder in the filesystem sense of the term.
Typically, a Source Folder will always be at the top-level of a project
because it would be very complicated to do otherwise. Yet, I'm guessing
you could put it down lower.
Typically, the source folder of a Java project would be named 'src'.
Typically, the source folder containing JUnit tests in a Java project
(because you'd want to keep such tests unmixed with your deployable
classes) would be named 'test'.
You do not need to mark more than the top-level Source Folder. So, both
examples are wrong because with Source Folder at the top, everything
underneath it is a source folder too. However, we don't call them that
(read on).
Typically, all folders beneath a Source Folder are elements of a package
if you're working in Java. In other words, if my project FooProject has
a class, com.windofkeltia.foo.FooClass, you will see it in the file
system as:
workspace/FooProject/src/com/windofkeltia/foo/FooClass.java
You will see the JUnit test, TestFooClass, as:
workspace/FooProject/test/com/windofkeltia/foo/FooClass.java
In this normal circumstance, 'src' will be marked as a Source Folder,
but I do not have to mark com, windofkeltia or foo as Source Folders.
Last, do not create folders under source folders in a Java Project.
Create packages; Eclipse will create the filesystem folders.
I strongly suggest a tutorial such as
http://www.vogella.de/articles/Eclipse/article.html What is shown there
is how projects are built customarily.
Best,
Russ Bateman
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08595 seconds