Java internal byet code, jvm, library and Hello World program explanation how it works

Java Internal:

 Java internal and Hello World program explanation how it works:- Detached from the syntax of Java, which is the focus of this article I would like to give you three particularly important terms at this point from the complex world of Java internal. These terms are not relevant to actual programming if you use them but you will understand better how Java works behind the scenes works.

Java Internal Byte code:

The javac command converts the source code of your program into a binary representation called a byte code. This transformation does several things:

  • First, ensures successful conversion to byte code, that your code is syntactically correct.
  • Second, thanks to the optimized presentation of the program.
  • And third, the byte code is platform-independent. That means, that for example a Java program compiled under Windows can later also be run under Linux.

Java byte code is always stored in files with the extension .class.

Java Internal Virtual Machine:

 For the actual execution of the byte code the java command is responsible. It passes the byte code to the so-called Java Virtual Machine (JVM). The integrated in the JVM Just-in-time compiler (JIT compiler) converts the byte code into Machine code of the respective hardware platform. The JVM with the JIT compiler is a basic component of the Java Runtime Environment (JRE).

The JVM provides the Java program with auxiliary functions and takes care of things that are no longer needed Objects automatically by the so-called garbage collector removed from memory.

Java Internal library:

When programming in Java it is not necessary to constantly reinventing the wheel. There is a huge foundation of frequently required basic functions that you can build on. Countless packages with classes and methods from Sun and Oracle developed Java library waiting to be discovered by you and to be used.

Hello World Program Explanation:

I still owe you the explanation of what the five lines of Hello World codes actually mean. After all, it’s not about that already the first lines of code are incomprehensible, right? Unfortunately, it is an exact one Description of “Hello World!” Is more complicated than you might think. Don’t expect to really understand the following paragraphs right away.

class HelloWorld {

The class keyword introduces the code for a class. One class is a closed code area. The structuring of code in classes offers a lot of advantages, both when using these classes in other Code parts as well as dividing the code into manageable one’s Code servings. Class is followed by the name of the class. It is common for the class name to always start with a capital letter. Follows the class name finally, the code that defines the functions of the class. So that the Java compiler knows where this code begins and where it ends, at Start the bracket {and at the end of the class the bracket}.

public static void main (String [] args) {

The actual code of a class consists of so-called methods. in the Hello World program, there is only one method called main. This method is of paramount importance because it is used as a starting point of the program applies. So the execution of a Java program begins always in main.

The main method has three special properties. You will go through Expressed keywords that come before the method name:

  • The method is public, i.e. public or externally accessible and not hidden within the class.
  • It is static. That means the code of the method is executed without an object of the class (an Instance of the class) must be created.
  • The method does not produce any result. This is indicated by the keyword void down (literally translated: “void, empty”).

The method name main is followed by a in round brackets List of parameters. main has exactly one parameter that we args have called. String [] means that several strings are attached to this parameter can be passed (actually an array of Strings). The character strings contain the parameters that were set when starting a Java program can be specified. Our Hello World program does not evaluate the args parameter at all. Nevertheless, the parameter and the data type String [] must be specified will! If you forget this, the Java compiler will not recognize main as a start method. When trying to run the Java program, the Error message that a (correct) main method is missing. The code of the method begins with the bracket {and ends with the associated one Bracket}.

System.out.println (“Hello World…”);

System.out.println gives the following, given in round brackets Parameters on the screen. In our example program it is a string that in Java is in quotation marks can stand. println can also output numbers and other data. println is a predefined method in the Java internal library. You can use this method without having defined it yourself beforehand. Methods are usually applied to objects. As an object in this case the standard output, with the output on the screen or to the currently active terminal. Access to the Object is done here by System.out. System denotes the name the system class, which is also specified by the Java internal library. out is again a static variable (an attribute or field) of this class, which points to the standard output object. This object is generated automatically by Java when the program is started.

For the sake of completeness, it should be mentioned that the system class located in the java.lang package. Because this package is particularly important classes or types, these may be used without java.lang to put in front. (The Java library contains many other packages Use, however, requires an import statement or explicit mention the package name.) Like all Java statements, the entire statement ends with a Semicolon. Forgetting this is one of the most common mistakes Java Inevitably for beginners.



The program code ends with two curly brackets. The first indicates that at this point the definition of the method’s main ends. The second bracket makes it clear to the compiler that now the class code comes to an end.

Related Article:

Java Hello World First Program and Vm Error Fixing

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button