Article
Getting Started with Java
Looking to learn how to build dynamic Web sites? There are many options out there, the most popular of which include ASP, PHP, and other scripting languages. Another option is Java. Oh sure, Java began as a language for writing Web-based Applets and cross-platform applications, but in the past few years its role has been expanded to include server-side programming of Web pages. In fact, there is great demand in the job market for developers with experience in writing server-side Java applications. Your first step towards adding these skills to your résumé should be to pick up a basic understanding of the Java language in general.
This is the first in a series of articles that will teach you the Java programming language with an eye to features and techniques that are applicable to building dynamic Web sites. Specifically, after covering the basics of the language and the object-oriented concepts you need to use the language effectively, I’ll proceed to a discussion of Java Servlets and JavaServer Pages (JSP), the two technologies used to build dynamic, data-driven Web sites using Java. Along the way, I’ll introduce you to related technologies, like Java Database Connectivity (JDBC). But before I get too bogged down in a description of things to come, let me turn your attention to the object of this article: an introduction to the basics of the Java language.
What Is Java?
Java is a full-featured programming language like C/C++, but simpler and more tightly structured. Like C++, Java is an object-oriented programming language, which is a concept I’ll expand on in the next article in this series. In basic terms, however, Java programs are written by creating a structured set of software components that interact with each other to produce the desired effect. These components are called objects, and the fundamental task of a Java developer is to determine the best object structure to achieve a system that works as required, as efficiently as possible and, wherever possible, producing components that may be reused in similar applications.
If all that sounds a little scary, don't worry; it'll all make sense once you've learned it. For now, we'll proceed in baby steps.
Java programs, instead of running directly on a computer's operating system, run on a "Java Virtual Machine" (JVM), which itself is a program that runs on the computer's operating system. Since the production of Java Virtual Machines is highly standardized, incompatibilities between different platforms are minimal. This means that, in theory, any operating system that has a JVM (pretty much all major operating systems these days) can run any Java program, with no need to recompile the program for each platform. This leads to one of the most attractive features of the Java language: "Write Once, Run Anywhere" (WORA). The disadvantage is that Java programs tend to run slower because the Virtual Machine has to convert Java program instructions and pass them to the operating system on which it is running.
Most current Web browsers can also run Java programs that are downloaded from the Web, either using a JVM built into the browser (as in Netscape 4 and Internet Explorer browsers), or by interfacing with a standard JVM installed separately (as in Netscape 6 and Opera browsers). Java programs designed to run in Web browsers are called Java Applets. When Java was originally released, much of the marketing hype surrounding the language centred on these little programs that run in Web browsers. Over the years, however, the focus of Java on the Web has shifted to server-side applications (including Servlets and JSP), and Java applets have been replaced in many instances by more nimble technologies like Dynamic HTML and Flash. Common uses of Java applets these days include Web-based chat programs and online games.
Now that you know what you’re getting yourself into, it’s time for you to get a hold of the tools you’ll need to get started with your Java development efforts.
Kevin began developing for the Web in 1995 and is a highly respected technical author. He wrote