How to Run Java Program ? CMD And Eclipse

run-java-program

There are two ways to Run Java Program.
  1. Run java program in Cmd.
  2. Run java program in Eclipse Ide.

1)  Run java program in CMD


  • Firstly, you could download the JDK because it is a necessary thing when you run java program
  • subsequently, make a new folder and the name the folder is "java" in your Desktop.
  •  After that open the notepad(editor) which helps to write code and type the simple java program as below.

    class HelloWorld
    {
        public static void main(String[] args{
            System.out.println("Hello, World!");
            System.out.println("Welcome to java overflow");
        }
    } 
  

  • copy the code and past your editor.
  • After save Run java program name  >  HelloWorld.java
  • you can understand first of all the file name and class name is equal because if you don't do it so you phase error so I suggest.
  • Then after open the run menu you show at the image and after type CMD then press the enter.
  • After that, you set the program folder pathname which is given by yourself 
  • our case, this code looks like > cd Desktop > cd java

java program run in the CMD

  • Then type: javac HelloWorld.java 
  • Show your Java folder in the .class file generate it's your HelloWorld.class,
  • it's java compiler generate the .class file its "byte code" form.
.classfilecreate

  • Then type  > javac HelloWorld
  • Show the image in the wrong class name should be not allowed
  • So type carefully and type the right name and then hit Enter. 
  • Then java program run and show output your code.
cmd output

  • so it's all about in the Run java program in cmd

2)  Run java program in eclipse 


  •  After Download the Eclipse Ide in 👇below link (Relative your operating system)
  • After download the eclipse zip file to convert the normal file and open the setup.exe file.
  • click open and  run after install and accept all agreement and license

eclipseide

  • Click on the eclipse ide for enterprise java developers(you can also download Eclipse ide for java Developers)
  • After clicking on the launch and then one by one configuration the teams and condition
launch eclipse ide

  • open the eclipse and show this below view👇
  • Create a new java project and give the name of the run java program
java program run in the Eclipse

  • Ignore modify filename and enter don't create
ignore modify file
  • Click on the src folder and create a new java class file the same as the picture
create new class

  • Copy This code and run a java application
 class HelloWorld
    {
        public static void main(String[] args{
            System.out.println("Hello, World!");
            System.out.println("Welcome to java overflow");
        }
    } 

hello world java program

  • right-click on the src folder and run as a java application and hit the enter
run configuration




  • show This run button end hit enter.
  • show console in the output.
output hello world
  • above all process to write java code in java enterprise edition so it's difficult but in the future, this is a good habit for involving a good developer category
  • so above all things should be Run java program in Eclipse ide

Post a Comment

Previous Post Next Post