Monday, 7 September 2020

Write a note on compiling and executing a Java program

 Write a note on compiling and executing a Java program


First, we have to open a text file using notepad or any text editor and then write the java program and then save this java program by any name with extention java example <anyname.java>.
Now compile the java program and then run the java program.

Compilation process of java using command prompt:

  •    open command prompt
  •    goto the place where java program is saved.
  •    now type below command

                d:\> javac   <filename>.java


If no compilation errors are there then we get .class file which consists of bytecode.
Once after sucess compilation we have to run the java program

Process of running the java program using command prompt:

  •      d:\> java <file name>

    
     name of the file which consists of main method and main method should be public static void main(String args[]).
 This bytecode gets interpreted on different machines.

Java virtual machine (JVM) is responsible for allocating memory space.

No comments:

Post a Comment