Thursday, August 16, 2007

Java Application from Existing Source in Eclipse

For many newer people you may not find good documentation on how to quickly and easily create a new Eclipse project from existing java files. This is really easy if the source has an ANT build file but if you don't it becomes a little less obvious, at least until you have done it once or twice. Thus I thought I would blog about this simple yet not-so-well documented functionality.

Steps to create a project in eclipse from existing java files.
  1. Create an Empty Workspace in Eclipse (lets call it Test)
  2. Now Using your file browser go to the folder where the new .classpath and .projects are. This will be your "Test" folder under the workspace folder.
  3. From here drill down to your src folder. In this directory drag and drop the top level of the source code you have, for example mine is "com" folder and under this are all my packages and java files.
  4. Go up to the same level as the src folder and go down into your lib folder.
  5. In here copy all required JAR files that your java files have.
  6. Now go back into Eclipse and on the left under your Package Explorer right click the src folder and pick refresh. Do the same for your lib folder.
  7. Now right click on your project (in our example Test) . Select Properties. Pick "Java Build Path" on the left. Then click "Add External JARS.." on the right. Add all the .jar files you did in step 5.
  8. Thats it! You now need to do run and define what it is you're running but that is self-explanatory.
Good luck and leave me a comment if you have any questions or problems.

No comments: