How to start creating Java class in Eclipse

blog img

Create a new class

First you create a new Java project.

To create a Java class in Eclipse you need to use the new Java Class Wizard. The Java Class Wizard can be invoked in different ways. Any of the methods described below can be used.

>> By clicking the File menu.

Click File > New > Class

>> By clicking on the class drop down button on ribbon.

>> By right clicking in the anywhere on package explorer.

Using the new Java Class Wizard

  • The source folder automatically captures.
  • Package – keep it blank (Takes the default package)
  • Enter the name of the class
  • Select class modifier. Now select public
  • Select method – we choose public void main method.

You can click the Finish button to create a new class of Java. 

Package Explorer window

A class named Newly Generated Tutorials can be viewed in Package Explorer. The same appears in the editor area.

Auto generated Java Code

    public class Tutorials {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	
	  }
     }

Example Java Code

Sample Java Code

public class Tutorials {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("WELCOME to techsiter.com");
	   }
     }

Run the code

To run the code you have to press the play button which appears on the ribbon bar.

Result

Once the code is run, the result of the code can be viewed in the console window.

Share your thoughts

Your email address will not be published. All fields are required.

Related post

  1. How to creating a JAR? – it’s easy.

    Creating a JAR file in Java involves compiling your Java…

  1. What is a JAR file? – it’s easy to understand

    A JAR (Java ARchive) file is a package file format…

  1. Top 50 Java Interview Questions and Answers.

    Here are the top 50 Java interview questions and answers…

  1. How to installation – Eclipse for Windows

    Download the Eclipse Installer from the official website of Eclipse…

  1. How to download Eclipse for Windows or macOS.

    Open your browser and type https://www.eclipse.org.The download page lists a…

Popular post

  1. Eclipse IDE – Create New Java Project.

    Opening the New Java Project…

  1. How to start the project in android studio

    Android Studio Open the Android…

  1. How to use ACOSH function in excel

    The ACOSH function returns the…

  1. Complete Header tags in html – easy to learn

    H tags can be used…

  1. Best features in Python programme – easy to learn

    Python is the most widely…