Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Source folder vs Folder
Source folder vs Folder [message #520439] Fri, 12 March 2010 11:52 Go to next message
albertkao is currently offline albertkaoFriend
Messages: 46
Registered: February 2010
Member
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.
Re: Source folder vs Folder [message #520475 is a reply to message #520439] Fri, 12 March 2010 09:38 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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 #520638 is a reply to message #520475] Sat, 13 March 2010 15:58 Go to previous messageGo to next message
albertkao is currently offline albertkaoFriend
Messages: 46
Registered: February 2010
Member
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.

Re: Source folder vs Folder [message #520670 is a reply to message #520638] Sat, 13 March 2010 22:26 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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
Re: Source folder vs Folder [message #521269 is a reply to message #520439] Wed, 17 March 2010 00:44 Go to previous messageGo to next message
albertkao is currently offline albertkaoFriend
Messages: 46
Registered: February 2010
Member
Thank you!
Re: Source folder vs Folder [message #1058378 is a reply to message #520670] Mon, 13 May 2013 18:55 Go to previous messageGo to next message
Robert Utterback is currently offline Robert UtterbackFriend
Messages: 1
Registered: May 2013
Junior Member
Russell Bateman wrote on Sat, 13 March 2010 17:26
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'.


I know this is an old post, but... This is exactly what we're trying to do in our project but are wondering about the best way to keep the JUnit test from being deplyed in an EBA (or jar), for instance. Keeping the test folder as a source folder allows us to run the JUnit tests w/in eclipse at any time, but how do you keep the JUnit .class files from being included in the jar/eba file since both src and test .class files are combined into the same bin folder? Is the only solution to use Ant to build the eba/jar so that you can exclude those test classes?

Thanks for your help.
Re: Source folder vs Folder [message #1058426 is a reply to message #1058378] Tue, 14 May 2013 05:26 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Just turn on the ability for each Source Folder to define its own Output Folder and have you tests built somewhere other than the default. Or go the older route of putting them in a different Java Project that simply has the original/main Project on its Java Build Path.

http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-properties-build-path.htm


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Java was started but returned exit code=1
Next Topic:Android app project - tools need to be updated via sdk
Goto Forum:
  


Current Time: Fri Apr 26 22:29:21 GMT 2024

Powered by FUDForum. Page generated in 0.08595 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top