Saturday, October 15, 2011

The Bluffer's Guide to Java -1

No Web developer can afford to ignore Java, but it's a frontier world full of strange names and acronyms. So here's our non-definitive, partially inclusive guide to Java jargon. Just the thing to read before you go to that job interview where "knowledge of Java would be an advantage".

Background

Java started life at Sun as an object oriented embedded language for consumer devices called Oak. Sun released Oak as Java in 1995 after reworking it for the Web. The first version, Java 1, was embodied in the freely downloadable JSDK - Java System Development Kit. The current version is Java 1.2.2, known as Java 2.
Java is an architecturally neutral language with a similar look and feel to C++. Although it's a compiled language, the compiler produces Bytecodes designed to run on a JVM, a Java Virtual Machine, rather than target processor or Operating System.
Only the JVM need be implemented for a specific hardware platform and, in a perfect world, any program written in Java will run unchanged on any platform for which a JVM is available.
However, it's perfectly possible to write non-portable Java programs if you need to take advantage of platform-specific features. In order to ensure full portability, Java programs must be written to the JNI - Java Native Interface. The JNI also enables Java code running in a JVM to operate with applications and libraries written in other languages such as C++.
Adding to Java's flexibility, the Invocation API enables you to embed the JVM into a native application.

Applets, Servlets, Beans…

Java comes in three pre-packaged editions from Sun. J2ME - Java 2 Micro Edition, J2SE - Standard Edition, and J2EE - Enterprise Edition. J2ME is aimed at those producing embedded code for phones, set top boxes and other consumer devices. J2SE is aimed at application and Web developers, while J2EE is aimed at those producing distributed enterprise applications.
Most Web users come across Java as Applets, intended to be downloaded with, and run within, a Web page. Sun originally released the HotJava browser with Java. Written in Java, it's a Web browser with a built in JVM. Both Netscape and Internet Explorer now include a JVM.
Running any downloaded program is insecure and Applets are therefore constrained to a Sandbox (unlike ActiveX). The Sandbox denies Java Applets direct access to the underlying hardware and OS. This enables end users to trust them. Applets cannot be run alone. Applets are simply a subset of Java programs, not intrinsically different.
In contrast, full blown Java applications are designed to be loaded and run locally with full access to local hardware and software via the JVM. Though there is a security model for Java applications based on policies which can restrict an application's permissions for network, file or directory access and so on.
Java has proved particularly popular for server side applications, thus the name, Servlets. In practice, a Servlet is a program which runs within a Web server similar to the way an Applet runs in a browser. You'd use one instead of a Perl CGI script, for example.
It's worth noting JavaScript isn't Java, it was developed as an interpreted HTML scripting language by Netscape to enable a greater degree of user/page interaction.
Java is an object oriented language. The underlying technology for implementing Java objects is JavaBeans. These are objects designed for intra-process communication. In effect, you bolt JavaBeans together to create Java applications.
In constrast, EJB - Enterprise JavaBeans - are objects designed for inter-process communication. EJBs support distributed processing. It's a fairly new and complex technology and quite distinct from JavaBeans despite the repeat of the name. Enterprise Java technologies are discussed more fully below.

No comments: