TAILIEUCHUNG - The Java Native InterfaceProgrammer’s Guide and Specification phần 4

Chương này minh họa làm thế nào bạn có thể nhúng một máy ảo Java của bạn bản địa ứng dụng. Một máy ảo Java thực hiện là vận chuyển như là một thư viện bản địa. Ứng dụng bản địa có thể liên kết chống lại thư viện này và sử dụng giao diện gọi để nạp máy ảo Java. | CHAPTER 7 The Invocation Interface This chapter illustrates how you can embed a Java virtual machine in your native application. A Java virtual machine implementation is typically shipped as a native library. Native applications can link against this library and use the invocation interface to load the Java virtual machine. Indeed the standard launcher command java in JDK or Java 2 SDK releases is no more than a simple C program linked with the Java virtual machine. The launcher parses the command line arguments loads the virtual machine and runs Java applications through the invocation interface. Creating the Java Virtual Machine To illustrate the invocation interface let s look at a C program that loads a Java virtual machine and calls the method defined as follows public class Prog public static void main String args Hello World args 0 The following C program loads a Java virtual machine and invokes . 83 Creating the Java Virtual Machine THE INVOCATION INTERFACE include define PATH_SEPARATOR define it to be on Solaris define USER_CLASSPATH . where is main JNIEnv env JavaVM jvm jint res jclass cls jmethodID mid jstring jstr jclass stringClass jobjectArray args ifdef JNI_VERSION_1_2 JavaVMInitArgs vm_args JavaVMOption options 1 options 0 .optionString USER_CLASSPATH 0x00010002 options 1 JNI_TRUE Create the Java VM res JNI_CreateJavaVM jvm void env vm_args else JDK1_1InitArgs vm_args char classpath 1024 0x00010001 JNI_GetDefaultJavaVMInitArgs vm_args Append USER_CLASSPATH to the default system class path sprintf classpath s c s PATH_SEPARATOR USER_CLASSPATH classpath Create the Java VM res JNI_CreateJavaVM jvm env vm_args endif JNI_VERSION_1_2 if res 0 fprintf stderr Can t create Java VM n exit 1 cls env - FindClass env Prog if cls NULL goto destroy .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.