Learn Java for Web Development

(Tina Meador) #1
CHAPTER 1: Introducing Java Web Development 11

Now that you have looked at the three key players that join forces in building modern Java web
applications (the JVM languages, Java EE, and the Java web frameworks), it is time to delve into
some specifics about Java.


The following section introduces Java so you can build your first stand-alone Java application. Since
this book is centered on web development using Java and is not about Java as a programming
language, the introduction to Java is brief—it’s just enough to help newcomers to the language
follow the subsequent chapters.


Getting Started with Java


A Java application is a computer program that executes when you use the java command to
launch the JVM. In the Java programming language, all source code is first written in plain-text
files (in Notepad, for instance, or in any text editor) with the .java extension. The source files are
compiled by the javac compiler into .class files that contain bytecode instructions. The JVM reads
these bytecode instructions and translates them into the machine-language operations that each
computer executes. By making the JVM available on many platforms, Sun transformed Java into a
cross-platform language. As shown in Figure 1-6, the very same bytecode can run on any operating
system for which a JVM has been developed.


Table 1-4. JVM-Based Web Frameworks


Web Frameworks Language Download From
Struts 2 Java http://struts.apache.org/download.cgi#struts
Spring Web MVC Java http://www.springsource.org/spring-community-download
JSF 2 Java http://www.oracle.com/technetwork/java/javaee/downloads/index.html
Grails 2 Groovy http://www.grails.org/download
Play 2 Java and Scala http://www.playframework.com/download

Java programJava compiler Bytecode

JVM for Windows

JVM for Unix

JVM for Linux

Figure 1-6. Cross-platform Java


Because the JVM is available on many different operating systems, the same .class files are
capable of running on Windows, Unix, Linux, or Mac OS. In the section that follows, I will show you
how to compile and run your first Java application. But first you need to set up the development
environment.

Free download pdf