Creating Java projects in Eclipse is very simple. To get started, I am assuming Eclipse is already downloaded and Java is installed. If not, you can download Eclipse here: Download Eclipse 3.4.1 and Java here: Download Java 6
To create a Java project, go to File > New > Project > Java Project
Click Next, and give your project a name, “Hello World,” leave the rest of the settings as is, and click ‘Finish.’ Now you will see a folder with your project under the tab Package Explorer. If you expand the folder, you will see JRE System Library. You can leave that there.
Now you will need to create a package to store your Java files. Under the Package Explorer, right click your project folder, and click New > Package. Give your package a name, such as “src.” This stands for source and will contain the Java files for your project. Once you have created the package, a subfolder with the name “src” will appear underneath your project folder. The little box next to “src” denotes that it is a package.
Java files will be added inside the “src” package. Right click the “src” package, and go to New > Class. A new window called ‘New Java Class’ will appear. Notice that some fields are filled in, such as the project name, and package. Under ‘Name’, create a name for your Java file, such as “Main.” If this is the class that will run the project, then you can check off the main method under ‘Which method stubs would you like to create?’ check ‘public static void main(String[ ] args)’ and click ‘Finish.’
Notice that the Java file, “Main.java,” appears under your package, “src.” Since the main method was checked off, Eclipse automatically adds the method in for you.
You can print something simple, such as “Hello World,” to the console. Type System.out.println(“Hello World”); inside the main method and save. The code example is below:
package src;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
To run the project, go to Run > Run As > Java Application. Another way to run the project is to go to Run > Run… A new window ‘Run’ will appear. You will need to fill out the Name, Project, and Main class. The name is anything you want to call this project when you want to run it. Name it something you will remember, such as “Run Hello World.” Project is the name of the project you want to run. You can search this by clicking on Browse… Lastly, Main class is the Java file where your main method is. You can also click Search… to find the Java file where your main method is located. Click ‘Run’ and Eclipse will compile your code, run the project, and print “Hello World” to the Console.
RSS Feed
Posted in
Tags: 

in java project, i can uesed the ‘back end’ exess.