Running compiled Java programs: To execute a compiled Java application (class files), what must be installed and running on the machine at runtime?

Difficulty: Easy

Correct Answer: Java virtual machine

Explanation:


Introduction / Context:
Java compiles source code (.java) into platform-neutral bytecode (.class). This bytecode is executed by a runtime environment that provides memory management, class loading, and just-in-time compilation, enabling “write once, run anywhere.”



Given Data / Assumptions:

  • We are discussing execution of already compiled class files.
  • A runtime is necessary to interpret or JIT-compile bytecode.
  • We are not building or compiling code at runtime.


Concept / Approach:

The Java Virtual Machine (JVM) is the runtime that loads class files, verifies bytecode safety, manages memory (heap/stack/GC), and executes the program. The Java compiler (javac) is needed at build time, not runtime. Bytecode is the artifact, not a program you “run” directly without the JVM. A web browser is optional and relevant only for legacy applets (now deprecated).



Step-by-Step Solution:

Compile source → produce bytecode class/jar files.Install a JRE/JDK that includes the JVM.Launch with the JVM (java command) which executes the bytecode.


Verification / Alternative check:

Attempt to run a class file without a JVM; the OS cannot execute it natively. With the JVM installed, the java MainClass command runs successfully.



Why Other Options Are Wrong:

Java compiler: for compilation, not execution.

Java bytecode: is the program representation, not an executable environment.

Web browser: unrelated except for obsolete applet technology.



Common Pitfalls:

Confusing JRE (runtime only) with JDK (runtime + compiler/tools); assuming native execution without a JVM.



Final Answer:

Java virtual machine

More Questions from JDBC, Java Server Pages, and MySQL

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion