Eclipse: Organising Files

1

I want to import a project that I'm planning to build upon. The problem is that it is very messy; with source files, class files and libraries under one directory. How would I organise these files using Eclipse?

I know you can change the source folder and output folder, but when I do change the source folder, the files that I want inside it do not physically move to that folder. Output folder is fine, though. Also, I would like a separate folder for libraries. I'm not sure how I would go about this, however.

Here's how I would like it:

src: This folder will contain source files.
bin: This folder will contain binary (class) files.
lib: This folder will contain external libraries.

someguy

Posted 2010-12-26T12:52:41.027

Reputation: 347

Answers

1

I know you can change the source folder and output folder, but when I do change the source folder, the files that I want inside it do not physically move to that folder

You are right: Eclipse won't move those files.

The simplest way to organize those files is to:

  • copy the sources in your 'src' folder.
  • copy the libraries in a 'lib' folder at the same level than src.
  • create an Eclipse project from existing source by selecting the parent directory of 'src' (that will generate your .project and .classpath right above your src directory).
    Don't select the default location (which would create the project in your Eclipse workspace).
  • you should see the lib directory right along src in your project. You can add any jar within it as library.

VonC

Posted 2010-12-26T12:52:41.027

Reputation: 13 292

The problem is that I have quite a number of sub-folders within the project, which contain source files and class files etc. etc., so copying only the source files that way is troublesome. I guess I could create the project, specify an output folder, which would move the class files out of the way automatically, and then do what you suggested. I'm disappointed that there is no simpler solution, though. Still, what I wanted was some advice from an experienced user, so thanks :). – someguy – 2010-12-27T18:24:11.337

@someguy: is there any way to quickly clean those subfolder from any non-source files (any non-java files for instance could be deleted, leaving you only with source files) – VonC – 2010-12-27T20:54:47.763

@VonC I can via NetBeans, but I want to use Eclipse, because I prefer it. I was hoping it would have built-in functions that allowed me to filter files. I know there is inclusion and exclusion, but I don't think it does what I want, and even if it does, I don't quite know how to use it. – someguy – 2010-12-28T15:17:38.930

@someguy: could you do it (the removal of all extra files) simply through an file explorer, through some search and filtering? That would be quicker. Then you refresh your (Eclipse) project and should be left with only what you need in it. – VonC – 2010-12-28T17:16:06.587

@VonC I could do that, but it would take a few minutes. Either way, there doesn't appear to be a quick, click-of-a-button solution. – someguy – 2010-12-29T16:03:07.753

@someguy: I agree, this doesn't seem to be a process managed completely from the IDE. – VonC – 2010-12-29T16:09:27.543