Google

Jun 14, 2014

Why use Java? Is Java 100% object oriented? What does Java comprise of? What is the main difference between the Java platform and the other software platforms? How would you differentiate JDK, JRE, JVM, and JIT?

Q. Why use Java?
A. One needs to use the best tool for the job, whether that tool is Java or not. When choosing a technology to solve your business problems, you need to consider many factors like development cost, infrastructure cost, ongoing support cost, robustness, flexibility, security, performance, etc.

Java provides client technologies, server technologies, and integration technologies to solve small scale to very large scale business problems.
  • Firstly, Java is a proven and  matured technology used in many mission critical projects, and  there are millions of developers world wide,  thousands of frameworks, tools, and libraries for it, and millions of sites, blogs, and books to find relevant information.
  • The emergence of open-source technologies has truly made Java a powerful competitor in the server and integration technology space. You can always find a proven framework that best solves your business problems.
  • The platform also comes with a rich set of APIs. This means developers spend less time writing support libraries, and more time developing content for their applications.
  • Built-in support for multi-threading, socket communication, and automatic memory management (i.e. automatic garbage collection). 

Q. Is Java 100% object oriented?
A. No. Is Java 100% OO? if yes why? if not, why not.


Q. What does Java comprise of?
A. Java comprises three components:

  • Java language comprising the syntax and semantics for programming has 3 editions – Java SE (Standard Edition), Java ME (Micro Edition), and Java EE (Enterprise Edition).

  • Java API (Application Programming Interface) is nothing but a set of classes and interfaces that come with the JDK. All these classes are written using the Java language and contains a library of methods for common programming tasks like manipulating strings and data structures, networking, file transfer, etc. The source *.java files are in the src.zip archive and the executable *.class files are in the rt.jar archive. There are 3 types of APIs available in Java technology.

Firstly, the official Java core API (i.e. src.zip and rt.jar) that is part of the JDK download. Secondly the optional Java APIs that can be downloaded separately. The specifications of the API is defined according to the Java Specification Request (JSR). For example, JSR 270 is the Java SE 6, JSR 168 is the portlet specification and so on. Finally, the third party libraries, which are unofficial APIs that are developed by third parties and and can be downloaded from the owner website. For example, http://www.apache.org/ where a number of handy APIs like Apache Commons, Apache Logging, and many more can be downloaded. Spring Framework, Hibernate, Struts, etc to name a few more.


Best Practice: It is a best practice to reuse proven and well tested APIs from Java Core, Java Optional, and third party APIs from Apache, Spring foundation, etc. It is also highly recommended to have these API documentation handy while coding to reuse appropriate well tested methods where possible without having to write your own.






  • Java Virtual Machine (JVM) is where all the classes written using the Java language and the API run on. The Java classes and API are platform independent but the JVM is not platform independent. You will find different downloads of the JVM for each Operating System (OS).


Q. What is the main difference between the Java platform and the other software platforms?
A. The Java platform is a software only platform, which runs on top of other hardware based platforms like Unix, Windows, etc.

  • Java source code is compiled into byte code that is understood by the JVM. Byte codes are the machine language of the JVM. The source code is easy for humans to understand. This enables a programmer to write programs. The byte code is very difficult for humans to understand. The first four bytes of every Java class (i.e the byte code) file are specified to be 0xCAFEBABE, a magic number that can help tools quickly differentiate likely class files from non class files.

  • Java Virtual Machine (JVM) – is a software that can be ported onto various hardware platforms. JVM interprets Java programs that have been compiled into byte code and usually stored in a “*.class” file. Byte code can be run on any computer that has Java interpreter (i.e the JVM). The JVM converts the byte code into platform (i.e. OS) specific executable machine language – a language understood by computers (i.e. binary 0s and 1s). The machine language is almost impossible for humans to understand. Every OS has its own machine language. 

Q. How would you differentiate JDK, JRE, JVM, and JIT?
A.There is no better way to get the big picture than a diagram.



JDK: You can download a copy of the Java Development Kit (JDK). Be sure to download a copy that is appropriate for your operating system and processor. The JDK contains the compiler (i.e. javac) and other programs and libraries (i.e. jar files) useful for Java development.



JRE: Java Runtime Environment is an implementation of the JVM. The JDK typically includes the Java Runtime Environment (JRE) which contains the virtual machine and other dependencies to run Java applications. The JRE is also available as a separate download if you have no interest in development and just want to be able to run Java applications. Remember to download a copy that is appropriate for your operating system and processor.



JIT: A JIT is a code generator that converts Java byte code into native machine code. Java programs invoked with a JIT generally run much faster than when the byte code is executed by the interpreter. The JIT compiler is a standard tool that is part of the JVM and invoked whenever you use the Java interpreter command. You can disable the JIT compiler using the -Djava.compiler=NONE option to the Java VM. You might want to disable the JIT compiler if you are running the Java VM in remote debug mode, or if you want to see source line numbers instead of the label (Compiled Code) in your Java stack traces. 

  • Is it possible to convert byte code into source code?
  • What are the 2 flavors of JVM?
  • What are the 2 bits of JVM?
  • What are some of the JVM arguments you have used in your project?
  • How do you monitor the JVMs?

Labels: ,

1 Comments:

Blogger john son said...

Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!..Thanks for sharing this wonderful blog..

JAVA J2EE Training in Chennai

5:31 PM, August 12, 2014  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home