Java HDF5 Interface (JHI5)

What it is

The Java HD5 Interface (JHI5) is a Java package (hdf.hdf5lib) that ``wraps around'' the HDF5 library.

There are a large number of functions in the HDF5 library (version 1.10). Some of the functions are not supported in JHI5. Most of the unsupported functions have C function pointers, which is not currently implemented in JHI5.

Java HD5 Interface (JHI5)
hdf.hdf5lib.H5. The H5 class calls the standard (i.e., `native' code) HDF5 library, with native methods for most of the HDF5 functions.

How to use it

The JHI5 is used by Java classes to call the HDF5 library, in order to create HDF5 files, and read and write data in existing HDF5 files.

For example, the HDF5 library has the function H5Fopen to open an HDF5 file. The Java interface is the class hdf.hdf5lib.H5, which has a method:

static native int H5Fopen(String filename, int flags, int access );
The native method is implemented in C using the Java Native Method Interface (JNI). This is written something like the following:
JNIEXPORT jlong
JNICALL Java_hdf_hdf5lib_H5_H5Fopen
(
 JNIEnv *env,
 jclass class,
 jstring hdfFile,
 jint flags,
 jlong access)
 {

 /* ...convert Java String to (char *) */

 /* call the HDF library */
 retVal = H5Fopen((char *)file, (unsigned)flags, (hid_t)access);

 /* ... */
}
This C function calls the HDF5 library and returns the result appropriately.

There is one native method for each HDF entry point (several hundred in all), which are compiled with the HDF library into a dynamically loaded library (libhdf5_java). Note that this library must be built for each platform.

To call the HDF `H5Fopen' function, a Java program would import the package 'hdf.hdf5lib.*', and invoke the method on the class 'H5'. The Java program would look something like this:

import hdf.hdf5lib.*;

{
 /* ... */

 try {
 file = H5.Hopen("myFile.hdf", flags, access );
 } catch (HDF5Exception ex) {
 //...
 }

 /* ... */
}
The H5 class automatically loads the native method implementations and the HDF5 library.

To Obtain

The JHI5 is included with the HDF5 library.