Ian Darwin: Java and the Meaning of Life

A Simplified, Rambling Overview

Java Logo Java Lobby logo

Java is a portable object-oriented computing language. Java was invented and released for everybody to use for free by Sun Microsystems, the Unix and networking company (NASDAQ: JAVA, formerly SUNW). BTW, it's Java, not JAVA - the name is a reference to the caffeine-rich drink, not an acronym (not even for Just Another Vague Acronym :-)).

One of Java's main benefits is portability; compiled Java programs do not have to be re-compiled to run on different platforms.

Ian F. Darwin, author of this site, is a Sun Certified Java Programmer and the original author of two courses on Java. Learning Tree Course 471, Java Programming Hands-On, provides a good introduction to the Java language and environment. His book The Java Cookbook provides an excellent second resource on Java. After you've learned the basics, get this book to learn your way around the many things you can do with Java.

Java Development

Programs are created by software developers in the Java Programming Language, possibly using a Java-specific visual development environment (IDE) analogous to Visual Basic. Java IDE's include Eclipse (originally from IBM), NetBeans (from Sun), Idea IntelliJ, and others.

Not all programmers like working in an IDE, though; you can program directly in Java using a graphical editor. The main command-line environments is Sun's Java Development Kit (JDK), also called the Java 2 Standard Edition (J2SE). The main versions of Java are by definition the main versions of Sun's JDK, that is, 1.0 and 1.1, and Java 2. Java 2 SDKs have continued the JDK numbering, so we have Java 2 SDK 1.2, 1.3, and 1.4. After that the SE editions were called Java 5, Java 6, and (soon) Java 7. There are also Enterprise Editions (see below), numbered J2EE 1.2, 1.3, 1.4, and Java EE 5 (and eventually Java EE 6).

HTML and the Web

HTML is an older (1990) texting language that is used to develop Web pages. By a "texting" language I mean a language that is stored in plain text on disk, like, for example, an autoexec.bat file - you can edit an HTML file with any plain text editor (e.g., "notepad" on MS-Windows), rather than being locked into a single vendor's closed undocumented proprietary format (like Microsoft Word, Word Perfect, etc). UNIX users can use vi or emacs, and there are special-purpose tools from many vendors and in open source. Netscape Composer's ("Edit Page") feature, Microsoft FrontPage, Adobe PageMill, all generate HTML.

Applets

One of the big pushes earlier on with Java was that web pages can be enhanced through "Applets" which can be imbedded in HTML pages. An Applet is a small, self-contained software component written in Java. An Applet can can do almost anything: generate graphics, prompt for information and process it, and can contain a full GUI interface inside a Web page.

This is a significant change in the Web which before Java was entirely server-based. Java is the client-side processing capability that makes the Web truly client-server for the first time. Other technologies such as ActiveX and Browser Plug-ins came later and offer certain features but include a vendor and platform lock-in which Java does not. Applets can be viewed in any modern Web Browser.

Microsoft, however, not one to be tied down to anybody else's standards, mutilated Java slightly, apparently to make Java on MS-Windows subtly incompatible with Java on other platforms. This lead to a lawsuit launched by Sun, which dragged on for a couple of years. The end result is that Micro$oft is abandoning Java and moving to its own .NET framework and Common Language Runtime. But Java continues to hold onto major developer momentum. And, very recently (2006), Sun and Microsoft have made up, and are working together.

Servlets

Just as an Applet is a tiny program that can be embedded in a web page to generate dynamic content, a servlet is a small program that can be loaded into a Web Server to generate server-side dynamic content and return it as a completed file to the browser. This enhances performance and gets away from the browser peculiarities that have plagued applets. The servlet can generate HTML, but can also generate XML, Acrobat PDF, graphics images, etc.

There are also JavaServer Pages and the newer JavaServer Faces, which run like servlets but are much easier to write - the main language is HTML, with bits of Java sprinkled in. Servlets and JSP are covered in Learning Tree Course 570; JSF in Learning Tree 936.

Note that most developers building Java-powered web sites use a "framework" like Struts, Spring or Seam in addition to JSP/JSF to get more work done more quickly.

There is even a compete web server writtin in Java; see The Tomcat Web Server.

The Java Enterprise Edition (Java EE, formerly J2EE)

The Java EE (Java Enterprise Edition) is an umbrella standard for all of Sun's server-side Java APIs. Java EE is currently the dominant server-side development framework.

Some of the main parts of the Enterprise Edition are:

There are Java EE Servers from many vendors; these are invariably written (almost) entirely in Java.

Not Just Another Pretty Page

It's important to note that Java can be used as a programming language just like C and C++ for many of the same applications that a developer would use C or C++. Using Java with Applets is just one special use. There are many, many Java API's available for programmers, including JDBC (replacing ODBC), networking, local files, windowing, etc -- almost anything you could do in C/C++, except maybe device drivers for MS-Windows or UNIX, could be done in Java.

Why Java?

Why would a programmer use Java? It is portable -- Java Programs need only be compiled once, and can run on almost any computer (UNIX, Mac, or PC with Windows). At present a Java interpreter is needed if you want to run Applications. However, modern Browsers include (or have available) a Java interpreter for running Applets.

Java is also a fairly pleasant language to learn, with many features that contribute to reliability:

There are many more - take 471 for more information!

Java is not JavaScript

Please also note that Java is not JavaScript.

JavaScript is NetScape's HTML scripting language. It was originally called LiveScript, but was renamed JavaScript in the initial excitement of Java. This may be a big issue because JavaScript has some security problems.

Executive Summary So Far

Java is used to write applets which are loaded on web pages, servlets/JSP and EJBs which run on the server side, and is a good all-round programming language.

Why Not Java? Security?

Why would companies not want their people involved with Java? Well, there may be security concerns because applets written in Java are downloaded onto your desktop computer. This is not new - it is just like every other item on the Web! Netscape downloads a copy of every Web page you visit to your local disk (unless you've disabled the Disk Cache feature, but it still downloads it "into" your PC - there is no way to stop this, it is how the Web works. Your Browser also downloads GIF images "into" your PC's memory, and SGML files, and PDF files, and everything else, including Applets.

If the person who wrote the applet wanted to and was knowledgeable enough, they could in theory write the applet with a virus that could do anything, from changing one file to destroying an entire computer system. However, this is much harder than writing a Windows virus, and is really quite rare - it only happens when somebody finds an implementation bug in the Java runtime.

If anyone mentions the security issues of Java, make sure they are not confusing it with JavaScript, which has many more security issues than Java. Particularly when combined with an insecure browser like Microsoft Explorer (do a Google search on "microsoft+explorer+script" to see how bad it is - Explorer will go down in history as the IIS of browsers).

Also, if someone is using Java as a programming language not in relation to Web Page Applets, then there are no real security issues. Java for use with non-Applet applications (including web servlets and JSP) is as secure as C, C++, Ada, etc., and also generally more reliable.

Java and ActiveX

ActiveX is Microsoft's Component Object Model. ActiveX is not a programming language. Java is a programming language. Therefore you can't compare them.

ActiveX compares to one of the many Java APIs, notably Java Beans. Beans is Sun's Component Object Model for Java. Both Beans and ActiveX have their place, but Beans is far more cross-platform. As well, there are real security problems with ActiveX, since it lets you download arbitrary machine code rather than carefully-controlled Java Byte Codes.

It seems safe to conclude that Java is here to stay.