Java Program Internal

    Program Internal

    Once we write a Java program, the Java compiler converts the source code into a bytecode that is platform-independent and can be run on any platform.

    We will discuss the work of compiling and running the Java program.

    What Happens at Compile-Time?

    Java has a Java compiler that converts the source code into the bytecode, which happens at the compile time. This bytecode is stored as the platform-independent class file and can be run on any system.

    What Happens at the Runtime?

    The classloader will load the class file that is generated after the code compilation. Classloader is the subsystem of the JVM . After the class file has been loaded, it gets verified by the bytecode verifier to check for illegal code that may violate access rights. The interpreter reads the bytecode stream to execute the instructions to provide the output.

    What happens at the run-time

    Points to remember

    1. You can save the code with any name other than the class name.

    When you compile the code, the .class file with the class name is created. When you execute the compiled file, it will be with the name of the class file.

    Suppose you save the code with hello.java with the class name as a bye. Javac hello.java -> compiler -> bye.class -> java bye

    2. You can have any number of classes within your source code.