4

I've been making small prototype programs recently, and it bothers me to have to set up the project each time. I have to import all the libraries, copy over an identical main class, then write a lot of code that I have already written before. Is there any way that I can save a project in Eclipse as a template, so that whichever programs I use the template for will have an identical classpath and original classes?

Thanks in advance.

1
  • 2
    Consider using Maven to automatically get your dependencies. Maven archetypes also help you to have some prototypes for a lot of technologies (Spring, Struts, GWT, etc...) May 24, 2013 at 15:08

3 Answers 3

1

You can copy (and paste) a project. Right click on the project (in the project navigator), and then paste. (CTRL+C then CTRL+V - or adjust if on on a mac)

I realize this is not as nice as a default, but it is a lot simpler than moving to maven.

3
  • Eh. This IS a lot simpler than switching to Maven. I'll probably just use this. Sorry to all the other answers.
    – Impmaster
    May 24, 2013 at 15:17
  • 1
    Note that it is simpler until e.g. you want to update a library version throughout all those projects. Of course, if you're a beginner, take your time - Maven is not rocket science, but it's not as trivial as some would lead you to believe either.
    – mikołak
    May 24, 2013 at 15:26
  • Maven is great once you get it running. But for a beginner, and especially in Eclipse, there are a lot of ways to get lost setting it up and also in how you compile/run your projects with maven. May 24, 2013 at 16:05
1

I think you want the same logics as the maven archetypes do. So you have to create your own archetype as a template for new programs and start with it.

Have a look over here - http://maven.apache.org/guides/mini/guide-creating-archetypes.html - this is a guide how to implement this.

0

Maven is the most robust answer (and I'd recommend at it as well). However, a more direct approach is to maintain an Eclipse workspace as a template. You can put the workspace (.metadata) folder in same location as your template projects. Then copy that folder structure to any new projects, including the .metadata folder. Switch workspaces to work on different projects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.