Java underlying call

Source: Internet
Author: User

In writing Java or android programs, it is inevitable that resources will be called locally. In this case, various files and various mechanisms will be involved, such as the JNI mechanism, which involves cross-platform calls, in addition to calling the platform's own classes and methods, it is another important platform design section for expanding its own resources. Here, the key point is that the resources of the operating system are called, which plays an extremely important role in improving efficiency and enhancing network programming.

Note that javax represents an extended class.

JNI is a Java Native interface that is called locally by Java. JNI is a method and a standard that enables the Java platform to call other libraries and methods such as C/C ++, such as dynamic link library DLL (note, static Link Library is Lib), declare that the called DLL uses system. loadlibrary (), and it must be in static. Declare the method of the loaded DLL, but do not need to implement its function body, because the function body is on the platform called by it (such as C/C ++ programming Windows System).

We should also clarify the differences between libraries and APIs, and the concepts of javah and javac. In fact, the difference between libraries and APIS is that libraries are called across platforms, while APIs are the methods provided by the platform itself. Javahis the interface between Java and C. You can find javah.exe in the jdkstore repository. .

Note that the various files, lib files, DLL files, H files (header files), class files, OBJ files, library files, and so on appear in the compilation process are very important concepts.

DLL is the dynamic link library of dynamic link library. Actually, it is equivalent to a class without a main function, that is, a method block. The key role is to be shared by other programs. It stores the specific implemented functions.

Lib files are divided into dynamic and static files. Static is the static Link Library Lib, and dynamic is the imported library Lib. The dynamic lib contains the declaration and implementation. After compilation, all the code is embedded into the host Program. Static lib only stores the Declaration. It is the declaration of the exported part. Its implementation part is stored in the DLL file. during compilation, only the exported declaration part is loaded. The specific implementation is in the DLL, it is equivalent to an H file.

The OBJ file is an intermediate file generated after code compilation and a binary file. You need to connect the connector with the resource file to generate an executable file (exe file ). The OBJ file uses the relative address, and the EXE file uses the absolute address.

The full name of the class file is the Java class file, which is the source file of Java. The characteristics of Java are different from the compiling method of C/C ++. The class file is a binary file and is cross-platform, it can run on all hardware devices and operating systems that support JVM virtual machines, and form bytecode after compilation to run on JVM.

JVM is a Java virtual machine. It is responsible for loading Java classes. The JVM contains class loaders, including root‑classloader, extension classloader, and application classloader. Rootcategory classloader is responsible for loading Java. * classes, extension classloader is responsible for loading classes contained in ext in javax. * and Lib in JRE of JDK path. Application classloader loads the class of the application.

The role of the H file (header file) is usually composed of two parts for the C/C ++ program as the header file and definition file. The header file is used to include function functions and data interface declarations, it is mainly used to save the file declared by the program, and the definition file is used to save the implementation of the Program.

The library file can be viewed as a repository, which provides variables, functions, and classes. After the evolution of "No repository-static Link Library-dynamic link library, the static Link Library cannot contain other static or dynamic link libraries, but the dynamic link library can. The program of the static Link Library will include the code in the final generated EXE file, the Dynamic Link Library does not.

A definition file is a file that helps detect harmful and unwanted software and prevents it from being installed or running on a computer. (Not understood)

In addition to the above files, the system class and runtime class should be used, which must be mastered by cross-platform applications. For the system class, the biggest function here is to load the library file system. loadlibrary () and load it by using javah as an H file. Runtimetimestamps run the command runtime.getruntime(cmd.exe C (). Therefore, the call and command sections are formed. But the two are not only used here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.