Skip to main content

JAVA: COMPLETE PROCESS TO EXECUTE JAVA PROGRAM.

JAVA.

Are you beginner? Wanted to known how java program works. How and where to type program? How to execute java program. Learn the following carefully and completely to understand.

Let us write and execute simple program to print HELLO WORLD. For that, first install jdk and keep java environment ready. 

There are only 3 main process to execute java program.
  1. Create the program.
  2. Compile the program.
  3. Run the program.

01.CREATE THE PROGRAM.
              This the process we create source code which is in the main part of program executing

There are 2 steps to create source code.

    1.Write the program.
                This is the first step we should write our program. We can type our program in any text editor. Here, i ll be using Notepad.

simple java program to print hello world
This is simple program to print Hello world in output screen.

    2.Save the program.
                After typing the program save(ctrl+s) the program with the class name.java extension. We must and should save it with class name. Remember it is case sensitive. If class name is capital letter, save the program in capital letters  
example:
        If your type class hello, you should save it with hello.java 


to save java program


Here. my class name is welcome, so i save as welcome.java. i save in a folder named javapro in desktop.

            
02. Compile the program.
                This is the process to translate source code, the program we write into an intermediate code called byte code (set of instruction in 1,0)
  • we should open command prompt. (windows log+R, type cmd, and OK.)
To open command prompt

  • you should change your path to where you saved the program. use the command cd pathname.
to cngange the path

Here, i set my path first to desktop and again folder name javapro on the desktop where i saved the program.
  • using the command javac classname.java we can compile the program.
to complile java program

Here, as my class name is welcome i type javac welcome.java and press enter. If any error it will indicate us, so that we go back to notepad and correct and save again.
  • you can also see the complied file in your folder.
see bytecode file

Here, welcome is program that i wrote, welcome.class is the complied file.

03. Run the program.
                This is the process to execute the program. It translate byte-code to machine understandable language, Finally we get the output to the program. 
                Using the command java classname  we can execute the program.
output of the simple program to print hello world

Here, as my class name is welcome i type java welcome and press enter, thus it gives the output.


Check out the interesting history of Java.

The important features of java.

Also the structure of java.

And the environment of java

Comments