Java Setup

         After Java 11 release we need to download JRE and JDK separately to download  .JDK is enough it is subset of JRE and it will give runtime environment also.

          Download JDK latest LTS Version from Oracle official website and set the environment variables if you are using windows.

  While learning don’t use Integrated Development Environment (IDE) instead use any basic text editors and save them with .java extension and run in cmd. Use javac command to convert java code to byte code which machine will understand.


The Way Java works:

           Create a source document where all code you wrote exists and now run the document through a compiler ., her the compiler checks for errors and won’t let you compile until you fix all the errors after all the errors are fixed compiler will creates a new document which is coded into java byte code which is extended with .class files. Now any device which is capable of interpreting the java byte code will run the code. The compiled code is platform independent. Now JVM which is there in the OS will translates the byte code into something platform understands and  run inside the machine will run the class file generated by compiler.


Code Structure in Java:

           In a source file put class inside class put methods which is behaviour of class and variables which is state of class. Hence object contains the behaviour and state of the class. Inside methods write statements.The main method is where JVM first runs. There should be on main method in entire application.



Note : Compiler compiles the code and generates the byte code.

           JVM runs the byte code .

Comments

Popular posts from this blog

JAVA Collections

JAVA Annotations