Chapter II Java Program Compilation and Operation Environment
2.1 JDK environment
Java is not only mentioned? Copy; a rich language and transportation environment, and also mentioned? Copy; a free Java Development Unit (Java Developers Kits, referred to as JDK). Compare people and the most user users to use this? Copy; tools to develop Java programs or call Java. JDK includes the following tools: Javac Java language compiler, output results for Java by Java Java by Java by Java Java Java by Java, JavaP Disassembeler: Java byte code division, this program returns to the Java program number of information and other information. JavaProf resource analysis tool, used to analyze where the Java program is called in the operation process, the number of calls; resources, including classes, and methods, and the time of the various data types. Javah C code processing tool, used to call the C code Java Applet Viewer Small Application Java Applet Viewer Small Application Program for Test and run Java Small Application Java Debugger API Java Trial Trial API Prototype Debugger Java Trial Trial Trial
Java open environment also includes Java class libraries (including I / O libraries, user interface libraries, network libraries, etc.) and Hotjava WWW browser. In the middle, Hotjava browser mentioned; a running system for running Java code in the WWW environment, and also promotes people from WWW; Copy; a Java off-frame frame. The Java interpreter is a separate running system for Java programs, which can run it stable and high performance. Copy; independent of the platform's Java bytecode, Java compiler is used to generate this? Copy; byte code .
2.1.1 Compilation of Java
The compiled program of Java is JavaC.exe. The javac command compiles the Java program to one-by-one code, then you can use the Java interpretator Java command to explain this? copy; Java byte code. The Java program source must be stored in the document of the .java. Every class in the Java program, Javac will be born with the same name as the class but the suffix is .class file. The compiler puts the .class file in the same directory of the .java file, unless you use the -d option. When you lead to a Copy; When you define a class, you must refer to its storage, which requires the use of environmental variable parameters ClassPath. The environmental variable CLASSPATH is composed of a path name that is separated by a partial space. If the class defined by the source file delivered to the Javac compiler is not found in this document, the document cannot be found in its document, the compilerator searches in the ClassPath definition. E.g:
ClassPath =.; C: / Java / Classes, the compiler first searches for the previous directory, if not search, continue to search the C: / Java / Classes directory. Note, the system always adds the system's directory defaults in the ClassPath, except that you use the -classpath option to compile. Javac_G is an unopened compiler for debugging, functionality and Javac. Javac is as follows: Javac [-g] [- o] [- debug] [- depend] [- NOWARN] [- verbose] [- ClassPath Path] [- NOWRITE] [- D Dir] file.java ...
The following is the interpretation of each option.
Selection explanation:
-CLASSPATH PATH Defining the path of the Javac search class. It will cover the default ClassPath environment variable settings. The path is made up of one? Copy; by a comma-separated path name, the general format is as follows:.;
-d Directory refers to the root of the class level, the format is as follows:
Javac -D
This will store the production of the .class file in the MyProgram.java program in my_dir directory.
-g belt adjustment information compiled, and the adjustment information includes a linear number of variables used to use Java trial tool. If the compilation is not added to the -O optimization option, only the line information is included.
-NOWARN closes warning information, the compiler will not display any warning information.
-O Optimization STATIC, FINAL, PRIVATE function, Note Your class file may be larger.
-Verbose
Let the compiler and the decreper show the named source document name and the name of the loaded.
Environmental variable
ClassPath uses to mention COPY; the default path of the class to the system searched the user. Each path is separated by the division, such as:
C: / Tools / Java / Classes indicates that the compiler encounters a new class, which first finds its definition in this document, if not, then in the directory of this file Find its definition in other files, if not, continue to search for all files in the C: / Java / Doc / Classes directory to push.
2.1.2 Trial of Java program uses Java debuggers
JDB Guide
The Java Detector JDB in the Betal version of the Betal in the earlier period is a command line, such as the SUN's DBX debugger. Use JDB to call Java applications, in the debug? REG; For example, the javac -g helloworld.javahelp command will display the list of available commands in the JDB.
> Help
2.1.3 Java program execution
Java - Java language soliter Java command to explain Java bytecode
Syndrome: Java [Options] ClassName
The classname parameter is the name of the class to be implemented. Note Any of the names of the class name will be delivered to the main function of the class to execute.
Java is launched after the main function, except that the non-main function creates one or more threads. If the main function creates its thread, Java is always waiting for the last thread to push it.
Option:
-cs, -Checksource When a compiled class is transferred, this option will change the time with source files than the source file. After the source file changes, you will re-translate this class and transfer to this new class.
-CLASSPATH PATH Defining the path of the Javac search class. It will cover the default ClassPath environment variable settings. The path is made up of one Copy; is composed of pathnames separated by a comma. The general format is as follows:.;
-MX X sets the maximum memory distribution pool, the size is X, X must be greater than 1000bytes. The default is 16 megabytes.
-MS X sets a small small size of the garbage back to X, and X must be greater than 1000bytes. The default is 1 mega.
-noasyncgc off turn off the trash recovery function. After this option is opened, in addition to non-explicit calls or prove memory, the waste memory does not return. When this selection does not open, the rubbish reception thread is in the same time when it is the same as the thread.
-ss x Each Java thread has two stacks, one is a Java code stack, one is a C code stack. The -ss option sets the stack setting for the line C-code C code to maximum X.
-oss X Each Java thread has two stacks, one is a Java code stack, one is a C code stack. The -oss option sets the stack set by the line of Java code to maximum X.
-v, -verbose allows the Java interpretation to print the corresponding information when each class is being transferred.
Environmental variable
ClassPath uses to mention COPY; the default path of the class to the system searched the user. Each path is separated by the division, such as:
C: / java / doc / classes; C: / Tools / Java / Classes indicates that the interpreter encounters a new class, which first finds its definition in this document, if not, in the directory of this file Find its definition in other files, if not, continue to search for all files in the C: / Java / Doc / Classes directory to push. 2.2 JWS environment
Java Workshop is a new product of Sun's company. It is an integration of Java language, which includes the following tools:
l Portfolio and Project Tricks L Source File Editor L Build Management Tricks L? Copy; Exhibition Online Super Text Connection to Help Document
This is a superconnection of a web page in Java Workshop's first page in Java Workshop, as shown in the figure:
Note that Java Workshop uses today's browser interface style. What do you want to do, just find the corresponding super connection, the specific compilation and debug function is implemented in an applet in the HTML document, therefore, This interface is easily accepted for users who are accustomed to browse by Internet.
2.2.1 Portfolio and Project Trick
ProtFolios is a set; Java application program or applet set. It makes you better managing more Projects. A Project is a subset in Portfolio, which contains the following information:
1. How to compile this item 2. How to call and browse this item 3. How to run this item 4. How to send this item
2.2.2 Source Document Editor
The source document editor can be entered from the super-level connection from the Build Tenrarometer, the debugger, and source file browser. In this module, you can enter the source file.
2.2.3 Build management tool
This module is an item's compiler. You can directly enter this module with a point build button. If a file is wrong, the error message will be mentioned? Copy; a super-level connection, directly refer to the wrong source document.
2.2.4 Visul Java (graphic interface structure? Copy;
Request, this module allows you to see the build? Copy; complex interface, if you have used Visual Basic, you will hang it very similar.
2.2.5 Detector
The debugger allows you to facilitate the misunderstandings of the program.
chapter summary:
The Java language has two open environments, one is the free JDK, which is the command line. There is also a Java Workshop, which is an encyclopedic environment for opening a Java program. This chapter is simply introducing their utility method.