Raw Native Interface Sample

This sample is located in \Samples\Native\Native_raw.

Note   It is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

This sample shows the native interface of the Microsoft virtual machine, native code operations that are garbage-collector safe, and native methods which encapsulate several Win32 functions (CreateEvent, PulseEvent, CloseHandle). The provided methods are implemented in a dynamic-link library (DLL). Various methods and variables are accessed from native code.

Using the Sample

To compile the sample

Use Nmake.exe to compile the makefile in the \Samples\Native\Native_raw directory. Type the following command:

Nmake

To run the sample

Run Go.bat in the \Samples\Native\Native_raw directory.

This displays the following output in the console window:

Square(5) = 25
iVar1 before = 5
calling DoubleInstanceVar()
iVar1 after = 10
    1    2    3    4    5    6    7    8    9   10   11   12
StaticMethod(10)
max value of array number 90 within the 2D array is  1234
JThread2 calling GCSafeNative()
JFoo() constructor with a parameter
JFoo() constructor without a parameter
JThread1: calling w32PulseEvent()
gcSafe.pJFoo1->m_iVal = 10   gcSafe.pJFoo2->m_iVal = 3
JThread2 completing
JThread1 completing

Key Project Files

JMain.java

This class's constructor loads a DLL file and calls various methods to demonstrate the interaction of Java with native code.

Technologies Demonstrated

Native Code

Microsoft Virtual Machine

© 1999 Microsoft Corporation. All rights reserved. Terms of use.