Introduction to Java

Java is an object-oriented programming language created by Sun Microsystems in 1996. It was originally designed by James Gosling. It was based on C++, but it had the added benefit of garbage collection and portability (cross-platform).

Java allows us to write the code once and run it on any popular platform, such as Windows, Unix or Linux, Solaris, Mac, etc. without having to re-compile. Therefore, Java’s slogan was “Write once, run anywhere”. Java programs are compiled into bytecode, an intermediate language that can be executed by a Java Virtual Machine (JVM). The JVM runtime sits on top of the Operative System (OS), interprets the bytecode, and executes it on the operative system.  This is how our code doesn’t become dependent to a specific platform. We just require a virtual machine for each platform, which already exist for most platforms.

During the internet boom in the 90’s, Java became very popular. You probably remember the famous chat rooms. Java allowed developers to add interactivity to web pages by writing little applications called “Applets”  that are executed by the browser.

In 1998, version 1.2 of Java was released, and it was named Java 2 Platform. This version was divided in three different editions: the Standard Edition (J2SE) for desktop applications, the Enterprise Edition (J2EE) for web and enterprise applications, and the Micro Edition (J2ME) for mobile devices and environments with limited resources. Later, in 2006, Sun released version 1.6 and renamed these editions to Java SE 6, Java EE 6, and Java ME 6, respectively.

With the open source movement, a lot of great free applications started to appear, and a lot of them were programmed in Java because of its cross-platform support. Java eventually became synonym of open source. In November 2006, Sun released Java as open source, under the terms of the GNU General Public License (GPL).

Development process

In order to create software with Java, we need to download Java’s Software Development Kit (SDK), also known as Java Development Kit (JDK). The JDK contains a JVM, which constitutes the Java Runtime Environment (JRE), and development tools to compile, debug, document, and even package our code, among others.

Java code is written in plain text and saved in files with .java extension. These files are then compiled into .class files by the Java compiler (javac.exe). These .class files contain bytecode specific to the JVM. In order to execute the code, the Java loader (java.exe) runs the bytecode on an instance of the JVM. Since there are JVM’s available for Windows, Linux, Mac, and Solaris, our .class file could be executed on any of these environments.

Since an application usually consists of many classes, multiple .class files are used. To make it easier to distribute, all the classes can be packaged into a single .jar file.

Usage and Technologies

  • Desktop applications: The Java API contains libraries like AWT and Swing to develop client applications that can run on different operative systems. Examples of applications written in Java are Limewire and OpenOffice.
  • Web clients (browser): Applets were very popular in the 90’s because they allow us to make web pages more interactive for the user. This is because we can make our Java code to be executed in the browser. All that it needs is a plug-in specific to the browser. All popular browsers support applets.
  • Hybrid: In December 2008, Sun released JavaFX, a platform for developing Rich Internet Applications (RIA), to compete with Adobe Flash Player and Microsoft Silverlight. A JavaFX application (widget) can run on the browser, like an applet, and then be dragged and dropped by the user onto the desktop, where it will keep running, even if the browser is closed. It will also be automatically installed in the user’s computer. A shortcut is also created on the desktop so the application can be re-launched at any time, without having to open the original web page.
  • Web Server: Java EE uses two technologies to work with dynamic html and allow us to create web applications: JavaServer Pages (JSP) and Servlets . A servlet is a Java class capable of processing http requests and generating a response. A JSP is basically a servlet, but expressed in a language similar to HTML. When a JSP is requested for the first time, it’s translated and compiled into a servlet. Any subsequent call to the JSP page is served by the servlet. Servlets are ideal to process requests from the user, while JSP pages are better suited to generate the html (response) that should be sent back to the browser.
  • Mobile devices: Java ME allows us to create application for mobile devices. It includes user interfaces, security, and networking capabilities. These applications are portable across many devices. Before the iPhone, most games for cell phones were developed with Java.
  • Databases: Java Database Connectivity (JDBC) API provides the functionality needed to access databases. Any data source can be accessed from Java as long as there is a JDBC Driver for that specific system. Drivers exist for most popular DBMS, such as MySQL and Oracle.

Nowadays, Java is one of most popular programming languages out there. It has grown into a very powerful platform to build software solutions for the desktop, the web, and even mobile devices.

Get Free Updates
Related Posts
Comments