Hey everyone,

In this post, I will discuss how to create projects within Eclipse.

Once Eclipse is installed (but I’m using portable version) and when you firstly run it. Follow the steps in order to create java projects :

1 – Click File menu or right click on the Project explorer.

2 – Select New menu and choose ‘Java Project’.

‘New Java Project’ wizard will open. The very first field is Project name, give it a meaningful project name. In this example, I’m giving it “Hello_World”. Make sure the latest or default JRE option is selected in JRE group. Then click ‘Next’ button. Next form allows you to check and modify Java build settings which you don’t really need to worry about now and simply click the ‘Finish’ button.

Now you can see your Project in Project Explorer. Double click on it, now you will see ‘src’ node right under the Project. Right click on ‘src’ node, select New menu and choose ‘Class’. ‘New Java Class’ wizard will open. Ignoring other advance fields, Simply enter the name of class in Class field. In this example, I’m using “HelloWorld”. Make sure modifier field is set to public and Superclass field is java.lang.Object. Also, tick the check box with public static void main(String[] args) and click ‘Finish’ button.

A new ‘HelloWorld.java’ tab will open in editor with code :


public class HelloWorld {



	/**

	 * @param args

	 */

	public static void main(String[] args) {

		



	}



}

Right after the line : public static void main (String[] args)

Add another line : System.out.println(“Hello World”);

And all together, It should look like this :


public class HelloWorld {



	/**

	 * @param args

	 */

	public static void main(String[] args) {

		System.out.println("Hello World");

	}



}

To run it, right click anywhere in the HelloWorld.java tab, select ‘Run As’ menu and choose ‘Java Application’.

That’s it for this post. I will come up with more Java tasks for my portfolio work. PK!

Tech Updates & Freebies

Tech Updates & Freebies

Receive tech updates, product reviews and patches, early wordpress codes and much more!

You have Successfully Subscribed!