期刊名称:Journal of Emerging Trends in Computing and Information Sciences
电子版ISSN:2079-8407
出版年度:2012
卷号:3
期号:10
页码:1398-1410
出版社:ARPN Publishers
摘要:SUN Java provides a mechanism for integration with functions coded in C/C++ or assembler, and basically offers two frameworks: Java Native Interface (JNI), and Java Native Access (JNA). In this paper, each of these two frameworks are first described, and then JNI is demonstrated with an example code, which uses Java code to write to the Windows Event Log through code written in C/C++. Event Log is a standard Windows OS feature and is used to log messages. Java usually does not use Windows Event Log to log messages, but in cases when it is necessary, this example demonstrates how it can be achieved. The beginning of this paper is dedicated to the JNI framework and data mapping, and the JNI interface pointer that allows C/C++ functions to interact with the JNI environment. Interaction in this case is bidirectional, which means that Java code is able to interact with code written in C/C++ and C/C++ code is able to interact with Java code. This paper provides a detailed description of the source code and a Visual Studio project for creating a C/C++ DLL library that is able to write to the Windows Event Log, and also offers a detailed description of source code of an Eclipse Java project that writes to the Windows Event Log through the C/C++ DLL library.