Wednesday, June 8, 2011

Opening existing Java projects in Eclipse IDE

I am currently working on developing a GUI  using Java Swing components and am using the Eclipse IDE (the current version is Helios) for it. I have used Netbeans as well but Eclipse seems to have a lot more plugins which adds to its functionality. For this project, I am using the Visual Editor plugin which can be downloaded from here. It has a palette view where you can drag and drop Swing components and add events to them with ease. A nice tutorial from IBM which should help you get started with the Visual Editor can be found here. I still however recommend learning a little about Swing components.

Now, I found a flaw in the Eclipse IDE. Ok, it may not be a flaw, maybe I just didn't know how to go about it. Opening existing Java projects in the Eclipse IDE was just not possible. You could only open Java files and when you run them, they would ask for an ant build and so on. I finally found a way around it. First of all, make sure your project folder is in the eclipse workspace folder. For me, the workspace folder was home/eclipse_workspace. Then, open the eclipse IDE and go to File>Import. In that, General>Existing Projects into Workspace. Then you browse for your project directory in the workspace folder and there you go. Its imported and you can Build and Run!

I don't know why the Eclipse developers would not make something as easy as File>Open Project. There might be another way around this. Do let me know through comments.

Tip: I came across this recently. For any Java file being developed using Eclipse, you can add packages required by the file with the shortcut Ctrl+Shift+O. All the required packages are automatically added.

1 comment:

  1. Hey..I always wanted to know how to do this. Thanks a ton!

    ReplyDelete