2003 34th Annual IEEE Computer Software and Applications Conference Workshops
CS1 and CS2 :write computer games in Java
Shin NAKAJIMAKeiji HOKAMURANaoyasu UBAYASHI
National Institute of InformaticsKyushu UniversityKyushu University
Tokyo, JapanFukuoka, JapanFukuoka, Japan
Email: nkjm@nii.ac.jpEmail: polikeiji@acm.orgEmail: ubayashi@acm.org
Abstract—Java has become a huge and complex technology platform, for developers, in order to better master the Java technology, in-depth understanding of the underlying technical processing details is essential. The mastery of the core concepts and ideas can help us learn by analogy, help us to enhance our understanding of the entire Java platform. Here are the Java technology platform described in several core concepts, which contains the ideas will help us a more profound understanding of Java technology.
Keywords :Java;Virtual Machine;Class file;API;
I. INTRODUCTION
Java is an object-oriented programming language, not only absorb the various advantages of the C + + language, but also to abandon the C + + difficult to understand the multi-inheritance, pointer and other concepts, so the Java language has a powerful and easy to use two features. Java language as a static object-oriented programming language representatives, an excellent realization of the object-oriented theory, allowing programmers to elegant way of thinking complex programming [1].
Java has the characteristics of simplicity, object-oriented, distributed, robustness, security, platform independence and portability, multi-thread, and dynamic [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications [3].
II. JAVAVIRTUALMACHINE
The main task of the Java virtual machine is to install the class file and execute the bytecode. The Java virtual machine contains a class loader that can load class files from programs and APIs.Only those classes that are required by the program to be executed in the Java API will be loaded. Bytecode is executed by the execution engine.
In different Java virtual machines, the execution engine may be very different. In the virtual machine implemented by the software, the simplest execution engine is a one-time interpretation of the bytecode. Another execution engine is faster, but also consumes more memory, called "just-in-time compiler". In this case, the first byte code to be executed will be compiled into the local machine code. The compiled local machine code is cached and can be reused when the method is called later. The third execution engine is the adaptive optimizer. In this way, the virtual machine begins by interpreting the bytecode, but it monitors the activity of the running program andrecords the most frequently used code segments. When the program is running, the virtual machine only compiles the most frequently compiled code into local code, and the other code is kept very frequently and is kept as bytecode - the virtual machine continues to explain them. An adaptive optimizer allows the Java virtual machine to perform optimized local code in 80% to 90% of the time, but only 10% to 20% of the code that affects performance.
When the Java virtual machine is implemented by the software on the host operating system, the Java program interacts with the host by calling the native method. There are two methods in Java: Java methods and local methods. Java method is written by the Java language, compiled into bytecode files, stored in the class file. Local methods are written in other languages (such as c, c ++ or assembly language), compiled into processor-related machine code. Local methods are stored in the dynamic link library, the format is proprietary to each platform. When a Java program calls a local method, the virtual machine loads the dynamic library that contains the local method and calls the method. The local method is to connect the Java program and the underlying host operating system connection method.
Access the underlying operating system resources. A local Native interface (JNI) - allows local methods to run on any Java platform implementation of a particular host system.
If you want to use resources on specific host, they can not access from the Java API, you can write a platform-related Java program to call the local method. If you want to ensure that the program platform independence, then only through the Java API to access the underlying system resources.
Figure 1 Java Virtual Machine Working principle
III.CLASS LOADER ARCHITECTURE
Java application can use two class loaders: the "bootstrap" class loader and the user-defined class loader. Starting the class loader (which is unique in the system) is part of the Java Virtual Machine implementation. The boot class loader typically uses a default way to load classes from a local disk, including the Java API classes (the boot loader is also known as the original class loader, the system class loader, or the default class loader).
Java applications can install user-defined class loaders at runtime, and this class loader can use a custom way to load classes. For example, download the class file from the network. Although the boot loader is an essential part of the virtual machine implementation and the user-defined class loader is not, the user-defined class loader can be written in Java and can be compiled into a class file that can be loaded by a virtual machine. As instantiated as other objects.
Because there is a user-defined class loader, so do not have to compile the time to know the running Java applications will eventually join all the class. User-defined class loaders make it possible to run extended Java applications. When it is running, the application can solve which additional classes it needs to be able to decide whether to use one or more user-defined class loaders to load. Since class loaders are written in Java, class loading is done with any style that can be expressed in Java code. These classes can be downloaded over the network, can be obtained from some databases, and can even be dynamically generated.
When each class is loaded, the Java virtual machine monitors the class and sees whether it is loaded by the class loader or by the user-defined class loader. When the loaded class references another class, the virtual machine loads the referenced class using the class loader that loads the first class. For example, if a virtual machine loads a Volcano class using a specific class loader, it will use the class loader to load all classes used by the Volcano class
Since the Java virtual machine takes the load of the class in this way, the loaded class can only see other classes that are loaded by the same class loader by default. In this way, the Java architecture allows you to create multiple namespaces in a Java application. Each class loader in the runtime Java program has its own namespace.
Java applications can create how many (or how many) classes that are loaded by different class loaders are stored in different namespaces, and they can not access each other unless the application explicitly allows it to do so. When writing a Java application, classes that are loaded from different source files can be separated in different namespaces. In this way, you can use the Java class loader architecture to control the interaction between the code loaded in any of the different source files, in particular, to prevent malicious code from gaining access to or damage to goodwill code.
The Web browser is an example of a dynamic extension that uses a user-defined class loader to download class files for Java applets from the network. The Web browser uses a Java application to install the user-defined class loader. This user-defined class loader is often referred to as the Java Applet class loader, which knows how to request a class file from an HTTP server. Java Applet can be used as a dynamic extension of the example, because the Java application does not know when it will start from the network to download the browser request class file. Only when the browser encountered a Java applet page, it was decided whether the need to download class files.
Web browser-initiated Java applications typically create different user-defined class loaders for each network address that provides class files, so different user-defined class loaders load different source class files. Which can be placed separately under the different namespace of the Java host application. Because different Java applet files are placed in different namespaces, malicious Java applet code does not directly access class files downloaded from other places. This can limit or prevent mutual access between code from different sources.
Figure2class loader architecture
VI. JAVA CLASS FILE
Java class files make Java more suitable for the network in terms of platform independence and network mobility. Its task in platform independence is to provide Java programs with binary forms of services that are independent of the underlying host platform. This approach breaks the tradition of C or C ++ and other languages, and programs written in these traditional languages are usually compiled first and then connected into separate, binary files that specifically support specific hardware platforms and operating systems. Often, binary executables on a platform can not work on other platforms. Java class files can run on any hardware platform that supports the Java virtual machine and the binary files on the operating system.
Figure3javaclassfile
When compiling and connecting a C ++ program, the resulting executable binaries can only be run on the specified hardware platform and operating system because the binaries contain the machine language for the target processor. The Java compiler to Java source file instructions translated into bytecode, this byte code is the Java virtual machine "machine language."
Class files are designed so that they can be quickly transmitted over the network. Second, because the Java program is dynamically linked and dynamically expanded, class files can be downloaded when needed. This feature allows Java applications to schedule the time to download class files from the network, thereby minimizing end-user latency.
Figure 4 java class
V.API
API (Application Programming Interface) is a pre-defined function, the purpose is to provide applications and developers based on a software or hardware to access a set of routines, without having to access the source code, or understand the internal work Mechanism details.
The standards currently applied to the API include the ANSI standard SQL API. There are also some other types of standards are still being developed. API can be applied to all computer platforms and operating systems. These APIs connect data in different formats. Each data format requires different data commands and parameters to achieve the correct data communication, but at the same time will produce different types of errors. Therefore, in addition to the knowledge required to perform data sharing tasks, these types of APIs must also address many network parameter problems and possible error conditions, that is, each application must know whether it has strong performance support for inter-program communication. On the contrary, since this API only handles an information format, the information delivery API in this case only provides smaller commands, network parameters, and subset of error conditions. Because of this, delivery API approach greatly reduces the complexity of the system, so when the application needs to achieve data sharing through multiple platforms, the use of information delivery API type is the ideal choice.
Information delivery: refers to the loose coupling or tight coupling between the application of small format information, through the direct communication between programs to achieve data sharing.
The standards currently applied to the API include the ANSI standard SQL API. There are also some other types of standards are still being developed. API can be applied to all computer platforms and operating systems. These APIs connect data in different formats. Each data format requires different data commands and parameters to achieve the correct data communication, but at the same time will produce different types of errors. Therefore, in addition to the knowledge required to perform data sharing tasks, these types of APIs must also address many network parameter problems and possible error conditions, that is, each application must know whether it has strong performance support for inter-program communication. On the contrary, since this API only handles an information format, the information delivery API in this case only provides smaller commands, network parameters, and subset of error conditions. Because of this, delivery API approach greatly reduces the complexity of the system, so when the application needs to achieve data sharing through multiple platforms, the use of information delivery API type is the ideal choice.
Information delivery: refers to the loose coupling or tight coupling between the application of small format information, through the direct communication between programs to achieve data sharing Remote Procedure Call (RPC): implements communication between programs by acting on a shared data buffer
Standard Query Language (SQL): is the standard access to the data query language, through the common database to achieve data sharing between applications.
File Transfer: File Transfer Data sharing between applications is achieved by sending formatted files.
Information delivery: refers to the loose coupling or tight coupling between the application of small format information, through the direct communication between programs to achieve data sharing.
Figure 5java relationship diagram of the collection class
Before a platform can even support Java programs, the API must be explicitly implemented on this particular platform. To access the local resources on the host, the Java API calls the local method. Since Java API class files call local methods, Java programs do not need to call them again. In this way, the Java API class file provides Java programs with platform-independent, standard interfaces for the underlying host. For Java programs, the Java API has the same performance and predictable behavior, regardless of the platform. It is because the Java virtual machine and the Java API are explicitly implemented on each particular host platform, so the Java program itself can become a platform-independent program
The Java API also contributes to the Java security model. When the Java API method performs any potentially dangerous operation (such as making a local disk write), it checks through the access controller to verify that it is authorized. The access controller is a class that is used to perform a stack check and has decided whether or not to allow an operation.
VI. JAVA CHARACTERISTICS
Java has the following characteristics:
1.Simple: One of the principles of Java is to build a simple and easy-to-use system that allows users to start designing programs without having to be trained, so Java's syntax is as much as possible the current program is similar to many designers have used C and C ++ languages. Also, Java removed C,and C ++ many rarely used, difficult to understand or often confused function, a lot of inheritance, pointer and so on.
2.Object-Oriented Object-oriented Object-oriented is the concept and technology widely used in the information industry in recent years.It has many good features. Object encapsulation can make the object interface definition clear; inheritance can increase the reusability of the software, contribute to classification and template design. Implementing the object-oriented concept and its various good features is one of the design concepts of Java.
3.The development of distributed computer networks makes the application of information towards a distributed environment, So the modern information development language and the environment should be with the distributed characteristics and functions. Java has a network-enabled library that includes the ability to integrate with TCP / IP network communication protocols such as HTTP and FTP.
4. Robust The program written by Java is capable of running in a variety of situations and must have high stability. Java in the development of the time to add to prevent the memory is overwritten and data corruption related processing mechanism.
5.Security (Java) is designed for use in the network and distributed environment, so security is a very important consideration. Java has a number of simple to complex security measures, can effectively prevent the invasion and destruction of the virus occurred.
6.Architecture Neutral There are many different types of computers on the network, and there are very different differences from the central processor to the operating system. So it is quite difficult to make the application run on every
machine. For this purpose, the Java compiler can produce a structure-neutral object code file format - Byte Code. This bytecode can run on many different computers. 7.Multithreading Multithreading is one of the tools necessary to develop complex and powerful programs, and Java also supports this important feature.
Source file: Use a text editor, such as Edit or Notepad to write source files. unavailable
Word editor because it contains invisible characters. Will be compiled source files saved, the source file extension must be Java.
Compiler: The source file is compiled by the compiler (Javac.exe) to generate a bytecode file with a .Class extension. Bytecode files are composed of platform-independent binary code, which is interpreted by the interpreter as a local machine code.
Running Java programs: Java programs are divided into two categories - Java applications (Application) and Java applet (applet). Java applications must pass the Java interpreter (java.exe)
To explain the implementation of its bytecode file; Java applet can be supported by the Java standard browser to solve Release execution.
VII. CONCLUSION
The Java language is a rapid development of the computer language program, which profoundly shows the essence of the preparation of the program, coupled with its simple and rigorous structure and simple grammar for its future development and maintenance provides a guarantee. As a result of the network application supportand multimedia access, will promote the Internet and enterprise network Web applications [6]. In addition, in order to keep Java growing and advancing the Java community, Sun announced the opening of the Java core source code at the Java One Developer Conference to encourage more people to participate in Java community activities. From the Java community and IBM and other global technology partners in two areas of support, Java technology in innovation and social progress continue to play a strong and important role [4], and with the difficulty of writing its program so that more professionals will focus on Placed in the preparation of the Java language and the design of the framework [3].
ACKNOWLEDGMENT
The reported work here was conducted in collaboration with Ross JACKSON (ENSIMAG,France) and Kelly TOMWELL(Universite de Pierre et Curie,France) when they visited NII during their internship in the summer of 2003.
REFERENCES
[1]R.J(Bud)Bates. GPRS:General Packet Radio Service .McGraw-Hill, 2003, .
[2]Cameron,J.R. JSP & JSD the Jackson approach to software development .Silver Spring MD: IEEE Computer Society Press, 1983, .
[3]M.J.King,J.P.Pardoe. Program design using JSP a practical introduction .Basingstoke Hampshire: Macmillan, 1992, .
[4]James Goodwill. Pure Java Server Pages .Indianapolis Ind: Sams, 2000, .
[5]Gwenael Le Bodic. Mobile messaging technologies and services SMS EMS and MMS .New York: J.Wiley, 2005, .
[6] Henry Labord(?)re,Vincent Jonack. SMS and MMS interworking in mobile networks .Boston: Artech House, 2004,