Monday, November 26, 2007

Short introduction to Eclipse

Every day I can see many people working with some IDEs like Jbuilder X, and when I ask them why are they using it instead of Eclipse they usually say that they don't know how to work with it. This is a little introduction and I want to show the very basic functions of Eclipse.

First of all you need to have Eclipse. You can go to www.eclipse.org and download “Eclipse IDE for Java developers”. After that, if you open Eclipse you may be asked about your workspace. What the hell is that? It is a work environment, if you come from Jbuilder, this is a new concept. In a workspace you can have different projects connected in some how. For example, different exercises of the same course.

Now you can see a welcome screen. Do click in “Workbench”:

Do “File -> New -> Java Project” and choose a name for the project and click Finish. Other options are irrelevant at this moment. I have called my project “Example”.
At the left side of Eclipse window you can see a bar called “Package Explorer”. This bar contains all projects you create. Do right click in src folder and choose “New -> Package” to create a new java package. I will called it “com.namespacecarballude”

To create a new class in the package you only have to perform a right click in the package you want, in this case “com.namespacecarballude”, and choose “New -> Class”. I will select “public static void main(String[] args)” and Eclipse will auto-generate a main method.

Write “System.out.println(“Hello World from http://NamespaceCarballude.blogspot.com”);” inside the main method. To execute and test the class, you have different ways. I usually press SHIFT+ALT+X and then J. If not, you can perform a right click in Test class and choose “Run As -> Java Application”.

If you want to save your work and transfer it to another computer, you only have to copy your workspace directory and use it in the other computer.

At this moment you can create projects, packages, classes inside packages and run them. It is not so much, but it is a start.

As always, if you see something wrong, feel free to correct my writing; I'd appreciate it and I will try to fix the mistake as soon as possible.

No comments: