Quick bite on Java programming language

Java logo In this post we will glance through my study notes on overview of Java programming language which is primarily sourced from Wikipedia. The intent of sharing this post is to make my study notes available to everyone for a quick reference.

• Java programming language is a concurrent, class-based, object-oriented language and is specifically designed to have lesser implementation dependencies.

• As of 2016, only Java 8 is supported (“publicly”). Major release versions of Java, along with their release dates:

JDK 1.0 (January 21, 1996)
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)

• All code is written inside classes, and every data item is an object, with the exception of the primitive data types, i.e. integers, floating-point numbers, boolean values, and characters, which are not objects for performance reasons.

• Unlike C++, Java does not support operator overloading or multiple inheritance for classes, though multiple inheritance is supported for interfaces. This simplifies the language and aids in preventing potential errors and anti-pattern design.

• Anonymous classes post compilation have class file names as concatenation of the name of their enclosing class, $, an integer.

• Static methods cannot access any class members that are not also static.

• The method name “main” is not a keyword in the Java language. It is simply the name of the method the Java launcher calls to pass control to the program. public static void main(String… args)

• The System class defines a public static field called out. The out object is an instance of the PrintStream class and provides many methods for printing data to standard out, including println(String) which also appends a new line to the passed string.

• Servlets are server-side Java EE components that generate responses (typically HTML pages) to requests (typically HTTP requests) from clients. A servlet runs on the server side.

import java.io.*;
import javax.servlet.*;

public class Hello extends GenericServlet {
    public void service(final ServletRequest request, final ServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html");
        final PrintWriter pw = response.getWriter();
        try {
            pw.println("Hello, world!");
        } finally {
            pw.close();
        }
    }
}

• GenericServlet class provides the interface for the server to forward requests to the servlet and control the servlet’s lifecycle.

• service(ServletRequest, ServletResponse) method defined by the Servlet interface

• The service() method is passed: a ServletRequest object that contains the request from the client and a ServletResponse object used to create the response returned to the client.

• JavaServer Pages (JSP) are server-side Java EE components. JSPs embed Java code in an HTML page by using the special delimiters <% and %>.

• A JSP is compiled to a Java servlet, a Java application in its own right, the first time it is accessed. After that, the generated servlet creates the response.

• Java contains multiple types of garbage collectors. By default, HotSpot uses the parallel scavenge garbage collector (Enabled using -XX:UseParallelGC). For 90% of applications in Java, the Concurrent Mark-Sweep (CMS) garbage collector (-XX:+UseConcMarkSweepGC) is sufficient.

• The Java Class Library is the standard library, developed to support application development in Java.

• The Class Library contains features such as:

The core libraries include:

  1. IO/NIO
  2. Networking
  3. Reflection
  4. Concurrency
  5. Generics
  6. Scripting/Compiler
  7. Functional Programming (Lambda, Streaming)
  8. Collection libraries that implement data structures such as lists, dictionaries, trees, sets, queues and double-ended queue, or stacks
  9. XML Processing (Parsing, Transforming, Validating) libraries
  10. Security
  11. Internationalization and localization libraries

The integration libraries include:

  1. The Java Database Connectivity (JDBC) API for database access
  2. Java Naming and Directory Interface (JNDI) for lookup and discovery
  3. RMI and CORBA for distributed application development
  4. JMX for managing and monitoring applications

User interface libraries include:

  1. The (heavyweight, or native) Abstract Window Toolkit (AWT), which provides GUI components, the means for laying out those components and the means for handling events from those components
  2. The (lightweight) Swing libraries, which are built on AWT but provide (non-native) implementations of the AWT widgetry
  3. APIs for audio capture, processing, and playback
  4. JavaFX

• A platform dependent implementation of the Java virtual machine that is the means by which the bytecodes of the Java libraries and third party applications are executed
• Licensing and documentation
• Plugins, which enable applets to be run in web browsers
• Java Web Start, which allows Java applications to be efficiently distributed to end users across the Internet

Share your thoughts