welcome to googlefans

2006/2/7

javac the Java Compiler

@ 10:52 PM (72 months, 20 days ago)

Some programming languages, such as C and Fortran, are compiled languages: the source code is compiled into machine code that is unique to the target hardware platform and operating system. Other languages, such as like APL and lisp, are interpreted languages: the source code is executed by running it through an interpreter. Both approaches have their strengths and weaknesses. Compiled programs tend to be faster and more efficient, but the compiled program can be run on only one hardware platform and operating system. Interpreted programs tend to be less efficient but potentially can be run, without change, on any platform for which an interpreter exists.

Java is both compiled and interpreted. The Java compiler, called javac, compiles (translates) the Java source code into an intermediate-level code called byte codes. These bytecodes are not directly executable on any hardware platform that is currently in existence; rather, the codes are interpreted by the Java interpreter, which can operate either by itself or as part of a Web browser such as Netscape.

The fact that Java is both compiled and interpreted can give you, the Java programmer, the best of both worlds. A program that you write in Java will be efficient (because it is compiled) and capable of running on a multitude of platforms (because it is interpreted).

In this chapter, you learn the following:

  • How to get started with the Java compiler
  • The Java compiler is easier to use than it seems. You'll find that out when you compile and run your first Java program.
  • How the Java directories are organized
  • The Java Development Kit is split across a number of directories. This chapter covers those directories that are significant to the compiler.
  • How to use the various compiler options
  • The Java compiler supports a number of options that vary its operation. You'll learn about those in this chapter.
  • How to troubleshoot common compiler problems
  • You'll learn to recognize and solve some of the problems that you may encounter with the Java compiler, especially when you use it for the first time.

Finding javac on your system  求职, 招聘找易才网

The installation process that you completed in chapter 3 creates a hierarchy of directories, beginning with a directory called java. When we installed Java on our system, we put the java directory below a root-level directory called Languages, but you can put yours wherever you think is best, including directly below the root. After installation, then, we have the following directories on our machine:

The environment variables.

@ 10:51 PM (72 months, 20 days ago)

The environment variables are settings used to determine the HotJava and Java Interpreter environments for your system.

Read the rest of this entry ... (192 words left)

The Java environment tools

@ 10:50 PM (72 months, 20 days ago)

The JDK comes with a collection of tools that are used with Java programs to perform various functions. This section discusses these tools, and lists their various functions.The Java environment tools consists of the following:

Read the rest of this entry ... (336 words left)

Testing your installation

@ 10:48 PM (72 months, 20 days ago)

Now after all this preparation, let's see if our installation works. We would want to test both Java applets, and Java applications since each are handled differently by your system, and the Java environment. A Java application is just what the name implies-a stand-alone Java program that is executed on your system by using the Java Interpreter. A Java applet is usually a remote Java program executed by a Web Browser (Netscape 2.0 for example). wow goldThe Browser locates the applet by referencing its HTML tag (<applet code="myApplet" width = somewidth height = someheight> </applet>) embedded in a Web Page.

Read the rest of this entry ... (88 words left)