Thursday, December 7, 2017

Java Basic Programming with Eclipse IDE - 1



How to write a Java program and run in Eclipse IDE :

1) Download Eclipse in your machine . Click here to download.
2) Install Eclipse in your machine , before that ensure that JAVA is installed .
3) After installing both Java(To check Java is installed correctly ,
    refer "JMeter Introduction" Page) and Eclipse, Open the Eclipse by double clicking
    the eclipse icon.           
4) When Eclipse is Opened, it will ask for the WorkSpace ( it is nothing but where your
     projects will be stored), Create the WorkSpace by giving preferred name.


5) Once the Eclipse IDE is opened , you will be seeing 2 perspectives (Windows)

               1) Project Explorer -  where you can create packages , classes etc.
               2) Java Editor -  where you can write the Java coding .



6) Create a Java Project in Eclipse IDE(Hello World Project)

       1) Right Click in the Project Explorer and Select New > Java Project.
      2) Specify the name as "HelloWorld" in the Project Name and Click Finish.
      3) Then the project will be created in Project Explorer.



7) Create a Package in the Java Project

       1) Right Click in the "SRC" Folder and then Select New > Package.
      2) Give the Package Name as "com.HelloWorld" and Click Finish.
      3) Now you can see the "com.HelloWorld" Package in the Project Explorer.



8) Create a Class in the Java Project

       1) Right Click in the "com.HelloWorld" Package Name and Select New > Class.
      2) Give the Class Name as "HelloWorld" and Click Finish.
      3) Now you can see the "HelloWorld.class" is created in the "Project Explorer"
           and Default code is generated in the Java Editor.



9) How to Run and Print the "Hello World " in the Console

      1) Use "System.out.println("Hello World");" to Print the Hello World as the
           Output in the Console.
      2) Then Right Click in the Project and Select Run As > Java Application.
      3) Then "Hello World " Output can be seen in the Console.



10) HelloWorld Program

              package com.HelloWorld;

              public class HelloWorld {

      public static void main(String[] args) {

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

       }

               }

Thanks ,

A M Balaji

1 comment: