
Java Compilation and Execution: Process Explained
Table of Content:
compilation and Execution process
You have to create your program and compile it before it can be executed.You can use any text editor or IDE to create and edit a Java source-code file, source file is officially called a compilation unit. This process is repetitive, as shown in below.

For most computer languages, the name of the file that holds the source code to a program
is immaterial. However, this is not the case with Java. The first thing that you must learn
about Java is that the name you give to a source file is very important. For this example,
the name of the source file should be Simple.java
.
If your program has compile errors, you have to modify the program to fix them, then recompile it. If your program has runtime errors or does not produce the correct result, you have to modify the program, recompile it, and execute it again.
The Java language is a high-level language, but Java bytecode is a low-level language. The bytecode is similar to machine instructions but is architecture neutral and can run on any platform that has a Java Virtual Machine (JVM).Rather than a physical machine, the virtual machine is a program that interprets Java bytecode. This is one of Java’s primary advantages: Java bytecode can run on a variety of hardware platforms and operating systems. Java source code is compiled into Java bytecode and Java bytecode is interpreted by the JVM. Your Java code may use the code in the Java library. The JVM exe- cutes your code along with the code in the library.

To execute a Java program is to run the program’s bytecode. You can execute the bytecode on any platform with a JVM, which is an interpreter. It translates the individual instructions in the bytecode into the target machine language code one at a time rather than the whole pro- gram as a single unit. Each step is executed immediately after it is translated.
- Question 1: What is an assembly language?
- Question 2: What are the input and output of a Java compiler?
- Question 3: What is the command to compile a Java program?
- Question 4: What is the command to run a Java program?
- Question 5: What is the JVM?
- Question 6: Can Java run on any machine? What is needed to run Java on a computer?
- Question 7: If a NoClassDefFoundError occurs when you run a program, what is the cause of the error?
- Question 8: If a NoSuchMethodError occurs when you run a program, what is the cause of the error?
- Question 9: What is the statement to display the message "Hello world" in a message dialog box?
- Question 10: Why does the System class not need to be imported?
- Question 11: Are there any performance differences between the following two import statements?
import javax.swing.JOptionPane;
import javax.swing.*; - Question 12: Reformat the following program according to the programming style and documentation guidelines. Use the end-of-line brace style.
- Question 13: What are syntax errors (compile errors), runtime errors, and logic errors?
- Question 14: Give examples of syntax errors, runtime errors, and logic errors.
- Question 15: Why Generics are used in Java?
- Question 16: If you forget to put a closing quotation mark on a string, what kind error will be raised?