Microsoft SDK for Java

Msjavah

The Header File Converter for Java (msjavah) generates C language header files for Java classes.

Use the following command to run msjavah:

msjavah [options] <classes>

Msjavah Command-Line Arguments

options One or more msjavah options.
classes Names of the Java classes to create a C header file for. This argument is required.

Msjavah Command-Line Options

/classpath /ctors /d /helpers /noclinit /nocppconsts /nologo /nowarn /nowritebarrier /o /portable /v /?

Usage Notes

Unlike other utilities, you must give a Java class reference instead of a file name for the given class, as in the following example:

msjavah java.lang.Thread

One command can create multiple headers, and unless the /o option is included, a header file will be created for each class. For example, the following command line produces two header files, java_util_Hashtable.h and java_lang_System.h.

msjavah java.util.Hashtable java.lang.System

In contrast, the following command line generates a file called headers.h, which includes both classes.

msjavah /o headers.h java.util.Hashtable java.lang.System

Use the /portable option to create headers that suppress pragmas specific to the Microsoft compiler (and other compiler information) to ease portability. The following command line produces a portable file called headers.h, which includes several classes.

msjavah /o /portable headers.h java.util.Hashtable
    java.lang.System java.lang.Thread

Use the /helpers and /ctors options with the msjavah utility to generate inline Raw Native Interface (RNI) wrapper method calls. For example, the following class has a constructor and a static and a dynamic method.

class sample {
   void dynamicMethod (int i) {}
   static void staticMethod (String s) {}
   sample (int i1, int i2) {}
}

The msjavah utility generates the following native code.

C:\..\>msjavah /helpers /ctors sample

void nativeMethod () {
   GCFrame gcf;
   struct gc {
      Hsample *sample;
   };
   GCFramePush(&gcf, &gc, sizeof(gc));
#ifdef __cplusplus
   // Note that arguments are presented before the
   // class name, as arguments to the new operator
   // and not directly to the constructor.
   // Generated by /ctors.
   gc.sample = new (3, 10) Hsample;
   // Generated by /helpers.
   gc.sample->dynamicMethod(5);
#else
   /* Generated by /ctors */
   gc.sample = new_sample(3, 10);
   /* Generated by /helpers */
   sample_dynamicMethod(gc.sample, 5);
#endif
   /* Generated by /helpers */
   sample_staticMethod(makeJavaString("Hello", 5));
   GCFramePop(&gcf);
}

See Also

Msjavah Options

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