Monday, 30 June 2014

JVM and its components

BYTECODE 

    Bytecode is the compiled Java binary code and is the machine language for the JVM .
   -> When the JVM loads the class file ,it finds stream of bytecodes for each method of the class.
   -> The bytecode streams are stored into the method area of the JVM.
   -> The bytecode of a particular method is interpreted whenever that method is called in the course of running the program.
   -> The butecode is executed by interpreter or by JIT( Just-In-Time) compiler 
    
JVM 

       Java Virtual Machine -> It interprets the compiled Java binary code i.e. bytecode for a computer's processor .This machine exists only inside the computer memory. It is a stimulated computer and does all the major functions of a real computer.



JVM has various sub components internally. You can see all of them from the above diagram.

1. Class loader sub system: JVM's class loader sub system performs 3 tasks
      a. It loads .class file into memory.
      b. It verifies byte code instructions.
      c. It allots memory required for the program.

2. Run time data area: This is the memory resource used by JVM and it is divided into 5 parts
      a. Method area: Method area stores class code and method code.
      b. Heap: Objects are created on heap.
      c. Java stacks: Java stacks are the places where the Java methods are executed. A Java stack contains frames. On each frame, a separate method is executed.
      d. Program counter registers: The program counter registers store memory address of the instruction to be executed by the micro processor.
      e. Native method stacks: The native method stacks are places where native methods (for example, C language programs) are executed. Native method is a function, which is written in another language other than Java.


3. Native method interface: Native method interface is a program that connects native methods libraries (C header files) with JVM for executing native methods.

4. Native method library: holds the native libraries information.

5. Execution engine: Execution engine contains interpreter and JIT compiler, which covert byte code into machine code. JVM uses optimization technique to decide which part to be interpreted and which part to be used with JIT compiler. The HotSpot represent the block of code executed by JIT compiler.


 YOU CAN ALSO VIEW :

 Introduction to Java
 Java Editions

INTRODUCTION TO JAVA


DEFINATION
  
        " Java is an object-oriented language."  
                  
                     This particular statement is not false but it is also not correct. The complete statement would be

          "Java is a true object-oriented language."
  
                     Why did I add this word 'true' to its defination ?

           An OO language  can be either partial , true or pure . It is classified into these on the basis of usage of OO features -

       1) Partial - May or may not use OO feature in the program . Ex : C++
       2) True - The program must contain some OO features . Ex: Java
       3) Pure - Each and every instruction of the program must use some OO feature. Ex: SmallTalk

-----------------------------------------------------------------------------------------------------------------------------------------

HISTORY 
         
        Java was developed by James Gosling and his team of Sun Microsystems of USA in 1991. It was originally called Oak , but due to some legal snags it was renamed as Java . Its just a name and not a acronym.

Principles: 

There were five primary goals in the creation of the Java language 

1.    It should be "simple, object-oriented and familiar"
2.    It should be "robust and secure"
3.    It should be "architecture-neutral and portable"
4.    It should execute with "high performance"
5.    It should be "interpreted, threaded, and dynamic"

Major release versions of Java, along with their release dates:
·         JDK 1.0 (January 21, 1996)                                                                          James Gosling
·         JDK 1.1 (February 19, 1997)
·         J2SE 1.2 (December 8, 1998)                                                                     
·         J2SE 1.3 (May 8, 2000)                                                                              
·         J2SE 1.4 (February 6, 2002)
·         J2SE 5.0 (September 30, 2004)
·         Java SE 6 (December 11, 2006)
·         Java SE 7 (July 28, 2011)
·         Java SE 8 (March 18, 2014)


----------------------------------------------------------------------------------------------------------------------------------

MAIN FEATURES OF JAVA

1. Compiled and Interpreted

 Java has a two stage system. 
(i).Java compiler translates source code into bytecode instruction.

(ii).Bytecodes are not machine instructions and hence not executable. Therefore, in the second stage Java interpreter generates machine code that can be directly executed.

2.Platform Independent and Portable

Java programs are easily portable. Changes in the operating systems, processors and system resources do not force any changes in the Java programs.This is the reason why java has become a popular language for programming on internet .

    Portability is ensured in two ways :
    (i). Java compiler generates bytecode instructions that can be implemented on any machine.

    (ii).The size of the primitive data types are machine-independent.

3.True OO language

4.Robust and Secure
   
  (i).It ensure reliable code in many ways.It has strict compile time and run time checking for the data types.

  (ii).It also has automatic garbage collection thus relieving the programmers.   

  (iii).It also incorporates the concept of exception handling which captures errors and eliminates risk of            crashing the system.

  (iv).Absence of pointers in java ensures that programs cannot gain access to memory locations without          proper authorization.

Java has many other features - simple,small& familiar 
                                            - mutithreaded & interactive                      
                                            - dynamic & extensible code
                                            - distributed
-----------------------------------------------------------------------------------------------------------------------------------------
  

                                                                                                                                          read more >>

Sunday, 29 June 2014

HI CODERS !!!

                     “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."                                                           - Martin Golding

                     Newbie's into the world of programming find themselves surrounded by thousands of doubts . HOW SHOULD I CODE ? HOW MUCH TO CODE ?  WHAT CONVENTIONS TO FOLLOW ? and many more....

                               Don't be afraid to ask even the most silliest question, they will might lead you to think things out of the box . Don't be afraid of your code . Who cares if something gets temporarily broken while you move things around ? 

So just relax :D