Overview - Java Access to ADU Devices

Java applications access a Windows DLL by using a JNI (Java Native Interface) wrapper. The JNI wrapper is a C program that converts Java calls into C calls.

adujava.calls.jpg (14806 bytes)

This demo includes sample programs for the java application (AduJava.java) and the JNI wrapper (AduJava.c). The AduHid.dll library is provided by Ontrak Control Systems Inc as a binary file.

The run-time component of AduJava.java is the compiled byte codes in AduJava.class. The run-time component of AduJava.c is the AduJava.dll library. The following diagram shows how the source code relates to the run time components.

adujava.runtime.jpg (16761 bytes)

The AduJava example was created as follows:

  1. The AduJava.java main program is typed in using a text editor.
  2. The javac compiler converts the AduJava.java source code into AduJava.class byte codes.
  3. The javah tool creates the AduJava.h JNI header file.
  4. A text editor was used to create the AduJava.c source code file for the JNI wrapper.
  5. A C compiler creates the AduJava.dll wrapper library.
  6. The java launcher runs the AduJava application.

Here is a graphic of the files, tools and their relationships.


jni.overview.jpg (55539 bytes)

  • editor.gif (1186 bytes) The editor can be any ASCII text editor such as Notepad.exe. You use it to type in the Java code for the application and the C code for the JNI wrapper.
  • file.green.gif (1502 bytes) AduJava.java contains the source code for the java program.
  • tool.gif (1121 bytes) javac is the java compiler provided in the Java SDK. It reads the source code in AduJava.java and creates the byte codes in AduJava.class.
  • file.brown.gif (1372 bytes) AduJava.class contains the compiled byte codes for the AduJava.java program.
  • tool.gif (1121 bytes) javah is the JNI header file generator provided in the Java SDK. It reads the byte codes in the class file and generates a header file containing the prototypes for the JNI wrapper functions.
  • file.brown.gif (1372 bytes) AduJava.h contains the prototype declarations for the entry points into the wrapper library.
  • file.green.gif (1502 bytes) AduJava.c contains the source code for the wrapper library. You refer to the contents of the AduJava.h and AduHid.h files when you create this code.
  • tool.gif (1121 bytes) The compiler is a standard C compiler used to create the AduJava.dll wrapper library.
    (Note: For this demo I am including the linker as part of the compiler).
  • file.blue.gif (1397 bytes) AduHid.lib tells the linker the locations of the AduHid functions within the AduHid.dll.
  • file.brown.gif (1372 bytes) AduJava.dll contains the executable binary for the wrapper library.
  •  file.blue.gif (1397 bytes)AduHid.dll contains the executable binary for the ADU device controller. This file is provided as binary only by Ontrak Control Systems Inc.

    Other Files

    Some other files are provided as part of the demo.

  • file.blue.gif (1397 bytes) AduHid.h contains the declarations for the entry points into the AduHid.dll library. Refer to this file to find the functions signatures needed to create the AduJava wrapper.
  • tool.gif (1121 bytes) setpath.bat contains a command to set the path to your java installation.
  • tool.gif (1121 bytes) compile.bat contains the commands to compile and link the wrapper library.

AduJava Help File Version
Copyright 2005 Ontrak Control Systems Inc.