Create first program in java

0
2341

In this tutorial today we will learn to create first program in java.Here we will display a text i.e print some text as an output.

  • Follow the steps given below to learn to create first program in java :

  1. First of all download Eclipse in your machine in which you will be developing your java programs.
  2. Once you get the Eclipse file downloaded in zip format just extract it.
  3. Now open the eclipse application .

  4. You will have the following window :

  5. Now go to File -> New ->Maven Project as shown below :

  6. After clicking on the Maven Project you will get the following dialog box :

  7. Just make a TICK on Create a simple project and click on the next button as shown in the image below :

  8. After clicking on next button a new dialog box will appear as shown :

  9. Enter the Group Id , Artifact Id and your project Name for example as MyProject
  10. Also enter some description about your project ..it can be anything related to you project i.e it will be a clue for you to identify about what this project is ?
  11. Hence after adding all this information your dialog box will appear as shown in the image.

  12. Now click on the Finish button.
  13. After clicking on the finish button your project will be created as shown in the image :

  14. Now double click on the MyProject and you will have the following expansion :

  15. Now lets create a package for our program :
  16. Now right click on src/main/java ->New ->other->General->Folder and click on the next button:

  17. When you select Folder and click on the next button you will have the following dialog box :

  18. Enter a package name here for example org and click on finish button :

  19. After clicking on the finish button your package will be created under your src/main/java as shown in the image .

  20. Now lets create a new package inside the current package .
  21. So right click on the org package org->New->Package as shown below :

  22. Thus you will have the following dialog box where you have to enter the new package name as shown :

  23. After clicking on the finish button your package will be created under your org package .

  24. Now lets create a new class , so right click on the package i.e org.intro->New->class

  25. After you click on the class you will get the following dialog box , enter the class name as shown :

  26. Click on the Finish button .
  27. Thus you will have your class generated :

  28. Now you can modify your code :
  29. Write the following code to display the entered text as an output :
  30. Here is the screen shot for it :

  31. Now select your class and run it you will have the following output:

  32. To run you java program from command prompt follow the steps given below :
    1. First of all save your program with java extension .
    2. For example lets save the same program in D drive .
    3. Now open your command prompt window

    4. Now navigate to your D drive because we have saved our program in D drive .

    5. Now enter the following command as :


    6. Now we are ready to compile our program , the command is :


    7. Now run it simply by entering the command as :
    8. Thus you will have the following output :

  33. Thus we have successfully learnt to create first program in java.

LEAVE A REPLY

Please enter your comment!
Please enter your name here