Start java programing in eclipse

Samsul Hoque
0
Downloading and installing

At first download JDK and install it.Then Eclipse IDE download.

The main page is http://www.eclipse.org/ ; start there for everything.
Click on "downloads" in either the main panel or the navigation panel; this will bring you to a page where you can select either the Main Eclipse download site or one of several mirrors. I suggest that you get the "Latest Release.

Getting started

After download ,unzip this file and open eclipse.exe.

Initializing Eclipse
When you develop Java applications in Eclipse, it stores all the created files in a directory called "workspace". When Eclipse is run for the first time, it will ask you where you want the workspace to be placed:





You can just use the default location or specify your preferred location. To avoid getting asked this question every time you start Eclipse, check "Use this as the default and do not ask again" option and press "OK" button. Once Eclipse finishes its startup process, you will see the following welcome window:


Click the "Workbench" icon on the right, which will lead you to the main Eclipse window:


Creating a Project
Now that you've got Eclipse up and running, it's time to create your first Java project. To do this, you'll want to go File -> New -> Java Project. After doing so, you'll see a window like the following:




Type your project name (say, HelloWorld) in the "Project name" field and click Finish. Then the name of your newly created project will appear on the left side of the Eclipse window (this part of the window is called "Package explorer pane"):




As you create more projects in Eclipse, other project names will appear in the Package explorer pane and you will be able to switch between your projects by clicking the name of a project.
Adding a Class  in Project
Now that you've created your first project, you now want to create a new Java file (with .java extension) and add it into your project. To create a new Java file, right click on the name of your project (HelloWorld) in the Package explorer pane and select New -> Class as follows:


This command will show you a window that looks like the following:



In the "Name: " section provide the name of the file (or the class) you want to create, HelloWorld, and click "Finish" button.




Congratulations! Now you have created your first Java code in eclipse. As you can see from the Package explore pane, your project now includes HelloWorld.java file. The "Editor pane" to the right of the Package explorer pane shows the actual content of the HelloWorld.java file, which simply declares HelloWorld as a public class. You can edit the content of the Java code inside the Editor pane.

Saving, compiling, and running Java code

Now let us learn how to code, compile and run a Java program in Eclipse. First copy and paste the following method into the HelloWorld class definition:
    public static void main(String[] args) {
      System.out.println("Hello world!");
    }




Now save the file by selecting File->Save, or pressing Ctrl-S (Option-S on Mac). When you save a Java file, Eclipse will automatically compile the file also, so that you don't need to compile it later when you want to run it.
Now that your code has been saved and compiled, you can run your program by selecting Run -> Run, or by pressing Ctrl-F11 (Option-F11 on Mac) or by clicking on the "Run" button 
near the top of the window. Once your program finishes running, you will be able to see the output of your program by selecting the "Console tab" at the bottom of the window.






Post a Comment

0Comments
Post a Comment (0)