high level language code written using an IDE or any given text editor. The source code file should always be saved with a .java extension. Example code:- public class HelloWorld { public static void main(String ar[]) { System.out.println(“Hello”); } } Save file as HelloWorld.java 2
into its native executable code Java compiles the source code into an intermediate byte code. This file is generated automatically with a .class extension, after the source code is compiled successfully. Example code:- 3 public class HelloWorld extends java.lang.Object{ public HelloWorld(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: getstatic #2; //Field ...contd Automatically generated file HelloWorld.class
a combination of – Java Virtual Machine (JVM) – it is a program that accepts the byte code (i.e. the .class file) and converts them to native executable code (binary code). JVM also includes other components i.e. memory management, just in time compiler and byte code verifier. Java API – these are a set of standard reusable class libraries made available in byte code format that provides a set of additional functionalities. 4 Native Code Every machine at its base only understands binary code. Native code is thus the actual executable code that delivers the final output under a given operating environment.