Compiling and Interpreting Applications in Java

Compiling and Interpreting Applications in Java. Learn How to compile and interpret your Java application.

Compiling and Interpreting Applications in Java

Compiling and Interpreting Applications in Java. Learn How to compile and interpret your Java application.

Compiling and Interpreting Applications

Welcome to Java tutorial series. In this lesson, you will learn about following topics:

For this tutorial you can use any text editor for writing the Java program and then use the command prompt to run the example code.

Compiling Java Program

For compiling Java program, first your code must write the code using text editor and save with .java extension. The file name must be the same as the class name.

After this you can compile your program using javac compiler, which translate java source code into java byte code. The output from a Java compiler comes in the form of Java class files with .class extension.

This video tutorial explains you the the process of compilation and interpretation of Java program.

Pursue the following steps to convert a Java source program into an object program:

  • First create the source code with text editor like notepad, jEdit, TextPad etc. Save it as .java file having same name as the class name.
  • Open a command prompt and change to the directory containing the source file.
  • Now we compile the created code, which is Greeting.java in this example. Type command javac Greeting.java on command prompt and hit Enter to compile your code.

This will produce one or more .class files, which are Java byte code.

Interpreting and running Java Program

Interpreting and running a Java program is process of executing the Java Program. In this process the Java VM is invoked and it takes the byte code and interprets it. In this process the byte code is converted to platform-dependent machine codes so that your computer can understand and run the program.

Once your program successfully compiles into Java bytecodes, you can interpret and run your applications on any Java VM or JVM enabled web browser as applet.

For running java code at the command line on Unix and DOS shell operating systems, you need to issue: java Greeting.

This command will interprets byte code hold by .class file and converts into machine specific binary code. Then JVM runs the binary code on the host machine.

What next? Check all the Core Java programming video tutorials.