How Files Are Organized
The truth is, it's entirely up to you. You have basically two options for organizing your files:
- Eclipse can do it for you
- You can do it yourself
If you're not interested in letting Eclipse organize your files for you, you may feel free to skip the rest of this page, and also skip setting up a workspace. When you read setting up a project, skip to the second half. If you'd like your files auto-managed, read on.
Workspaces and Projects
Eclipse uses two basic abstractions to manage your code:
- Workspace: A "working directory" for all of your projects. Think of it like "My Documents" in the Windows operating system. It's a folder which contains a lot of your documents, but there's nothing to prevent you from creating another folder called "My Other Documents" (for instance) to house other documents. Typically you only need one workspace, and you can think of it as your "My Documents" for Java code. If you wanted to, you could have more than one, but chances are you won't have a use for more.
- Projects: A collection of related code. Generally speaking, each project encompasses one independent program. Each programming assignment you do will typically require its own project.
In short, your workspace is going to contain a lot of projects. It will be the folder that holds all your projects. And that's mostly all it is: a folder on your hard drive.
Workspace and Project Organization
Whenever you make a project inside of Eclipse, Eclipse will auto-magically create a new folder in your workspace with the same name. Inside of that folder it will create two folders: bin, and src (source). The bin folder can be ignored. This is nothing more than the folder in which Eclipse stores the .class files generated by compiling your code (which it does automatically; see compiling). The source folder is where all of your Java files will be saved.
a project and its corresponding folders
So in the end, there's no voodoo going on under the hood. It's very simple. Your workspace is the containing directory for your projects, which are in turn directories named after the corresponding projects.
Pros and Cons
- You don't need to create directories or move files by hand
- Your workspace is self-contained. If you keep it on a flash drive, for instance, you can pop it into a lab computer, boot Eclipse, and just point Eclipse to your on-usb-key workspace directory and voila! All of your projects load, along with your project and workspace configurations.
- You can't put different projects in completely different directories without making separate workspaces.
- It may not always be clear to you where your stuff is.