Java tutorial - first program

Write your first program with Java

Now open text editor (e.g. Notepad) and type the following code:

public class HelloWorld
   public static void main(String[] args)
      System.out.println("Hello World");

Then save the code in bin directory (where you installed JDK) with the file name:

Note: The file name and the class name must be the same.

If you will use the Eclipse tool to develop your Java programs, you can follow the steps below to create your first project.

- Create a project by selecting the New->Java Project from the File menu.

- On the new Java project window, enter the name of the project. For the first program, the project name is HelloWorld.

create the first project in Eclipse

- Click Finish button to complete the new project set up.

- Create a new class by selecting the New->Class from the File menu. Enter HelloWorld in the Name text box and click finish.

create a new class in Eclipse

- You will get the HelloWorld class block as shown below. At the same time, in the src folder, the file is automatically created for you.

public class HelloWorld {


You can copy and paste the Java code shown above to override this code block. Now you are ready to run the program.


kumavat hitendra comment

 kumavat hitendra

My project


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.