- Explore the strengths of the Java programming language
- Understand what Java is
- Learn about the different versions and editions of Java
- Cover the history of Java
- See the purpose of the Java Virtual Machine
- Create a simple starter program in Java
- Compile, correct errors, and test a program
- Become familiar with one way to get answers about Java
- Understand object-oriented programming concepts
- Learn how to use objects already provided in the Java API
- Create objects using “new”
- Explore the use of the . (dot) operator to access data and invoke methods
- Learn how to create your own object types called classes
- Examine the role of class constructors and the default constructor
- Study the difference between class and object
- Learn the uses of the static keyword
- Examine how and why data can be associated with a class
- Learn what class or static methods are and where they are used
- Investigate the “this” keyword in Java and how it is used
- Survey the various scopes in Java
- Understand the purpose of garbage collection in Java and how it is managed
Java is currently the most popular programming language. Why? What made it so popular, and why is it used today in a variety of applications? From tiny applications that run on cell phones and embedded devices to huge distributed enterprise applications, Java has had an enormous impact on the software industry. Its presence has forced organizations like Microsoft to adopt a different approach to programming.
In a word, Java’s strength lies in its portability. The mantra by which all Java developers live by is “WORA,” or write once, run anywhere. What makes WORA work in Java?
This chapter introduces you to Java goals and philosophy. After reading this chapter, you will have a much better understanding of the Java platform and why it is so powerful.
You will be introduced to a simple Java application, the ubiquitous ‘Hello World’ application but written in Java. You will also gain an appreciation for how Java applications are built, compiled, and executed.
The Java Platform:
The Java platform has two components:
- The Java Virtual Machine (JVM)
- The Java Application Programming Interface (API)
In Java, applications are both compiled and interpreted. The Java compiler compiles your application source code to an intermediate language that is interpreted by the JVM. The intermediate language is called bytecode.
The bytecode is not machine code that gets executed directly. Instead, the JVM translates (i.e., interprets) the bytecodes into machine code, which gets run by the actual platform. In other words, bytecode is like the “machine code” for the JVM. The bytecode is platform independent and can therefore be interpreted by any JVM. JVMs are built specific to particular platforms (hardware and OS).
More information about the JVM is provided later in this chapter. In order to “run” your Java application, what is needed is both the Java API library used by your application and the JVM. The JVM and Java API required to run Java programs is called the Java Runtime Environment (JRE). The JRE does not include tools to create or develop Java applications. It is strictly the minimum software that must be installed on a machine in order to run Java applications.
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.