Create first program in java

0
2179

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. first program in java

  5. You will have the following window :
  6. 02

  7. Now go to File -> New ->Maven Project as shown below :
  8. java program

  9. After clicking on the Maven Project you will get the following dialog box :
  10. Create first program in java

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

  13. After clicking on next button a new dialog box will appear as shown :
  14. java programming

  15. Enter the Group Id , Artifact Id and your project Name for example as MyProject
  16. 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 ?
  17. Hence after adding all this information your dialog box will appear as shown in the image.
  18. programming in java

  19. Now click on the Finish button.
  20. After clicking on the finish button your project will be created as shown in the image :
  21. java

  22. Now double click on the MyProject and you will have the following expansion :
  23. 9

  24. Now lets create a package for our program :
  25. Now right click on src/main/java ->New ->other->General->Folder and click on the next button:
  26. first program in java

  27. When you select Folder and click on the next button you will have the following dialog box :
  28. create java program

  29. Enter a package name here for example org and click on finish button :
  30. 12

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

  33. Now lets create a new package inside the current package .
  34. So right click on the org package org->New->Package as shown below :
  35. java

  36. Thus you will have the following dialog box where you have to enter the new package name as shown :
  37. program in java

  38. After clicking on the finish button your package will be created under your org package .
  39. 16

  40. Now lets create a new class , so right click on the package i.e org.intro->New->class
  41. program in java

  42. After you click on the class you will get the following dialog box , enter the class name as shown :
  43. first java program

  44. Click on the Finish button .
  45. Thus you will have your class generated :
  46. java class

  47. Now you can modify your code :
  48. Write the following code to display the entered text as an output :
  49. Here is the screen shot for it :
  50. java program

  51. Now select your class and run it you will have the following output:
  52. java output

  53. 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. cmd

    5. Now navigate to your D drive because we have saved our program in D drive .
    6. java program in cmd

    7. Now enter the following command as :

    8. set path of java

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

    10. java compilation

    11. Now run it simply by entering the command as :
    12. Thus you will have the following output :
    13. output

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here