Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2026-07-28 The HDF5 Field Guide

Loading...
Searching...
No Matches
HDF5 Library Java Interface

## Detailed Description

This class is the Java interface for the HDF5 library.

This code is the called by Java programs to access the entry points of the HDF5 library. Each routine wraps a single HDF5 entry point, generally with the arguments and return codes analogous to the C interface.

See also
  H5, C-API
  HDF5 Library and Programming Model, User Guide

## Functions
static final int | getOpenIDCount ()
static final Collection< Long > | getOpenIDs ()
static synchronized native int | H5check_version (int majnum, int minnum, int relnum)
static synchronized native int | H5close () throws HDF5LibraryException
static synchronized native int | H5error_off ()
static synchronized native void | H5error_on ()
static synchronized native void | H5export_attribute (String file_export_name, long dataset_id, String attribute_name, int binary_order) throws HDF5LibraryException
static synchronized native void | H5export_dataset (String file_export_name, long file_id, String object_path, int binary_order) throws HDF5LibraryException
static synchronized native int | H5garbage_collect () throws HDF5LibraryException
static synchronized native int | H5get_libversion (int[] libversion) throws HDF5LibraryException
static synchronized native int | H5open () throws HDF5LibraryException
static synchronized native int | H5set_free_list_limits (int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim) throws HDF5LibraryException
static void | loadH5Lib ()

## Variables
static final String | H5_LIBRARY_NAME_PROPERTY_KEY = "hdf.hdf5lib.H5.loadLibraryName"
static final String | H5PATH_PROPERTY_KEY = "hdf.hdf5lib.H5.hdf5lib"
static final int | LIB_VERSION [] = {H5Version.MAJOR, H5Version.MINOR, H5Version.RELEASE}

## Function Documentation

## ◆ getOpenIDCount()

final int getOpenIDCount | ( |  | ) |
| static

Get number of open IDs.

Returns
  Returns a count of open IDs

## ◆ getOpenIDs()

final Collection< Long > getOpenIDs | ( |  | ) |
| static

Get the open IDs

Returns
  Returns a collection of open IDs

## ◆ H5check_version()

synchronized native int H5check_version | ( | int | majnum,
|  | int | minnum,
|  | int | relnum )
| static

H5check_version verifies that the arguments match the version numbers compiled into the library.

Parameters

  majnum | The major version of the library.
  minnum | The minor version of the library.
  relnum | The release number of the library.

Returns
  a non-negative value if successful. Upon failure (when the versions do not match), this function causes the application to abort (i.e., crash)

See C API function: herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)

## ◆ H5close()

synchronized native int H5close | ( |  | ) | throws HDF5LibraryException
| static

H5close flushes all data to disk, closes all file identifiers, and cleans up all memory used by the library.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5error_off()

synchronized native int H5error_off | ( |  | ) |
| static

Turn off error handling. By default, the C library prints the error stack of the HDF5 C library on stdout. This behavior may be disabled by calling H5error_off().

Returns
  a non-negative value if successful

## ◆ H5error_on()

synchronized native void H5error_on | ( |  | ) |
| static

Turn on error handling. By default, the C library prints the error stack of the HDF5 C library on stdout. This behavior may be re-enabled by calling H5error_on().

## ◆ H5export_attribute()

synchronized native void H5export_attribute | ( | String | file_export_name,
|  | long | dataset_id,
|  | String | attribute_name,
|  | int | binary_order ) throws HDF5LibraryException
| static

H5export_attribute is a utility function to save data in a file.

Parameters

  file_export_name | The file name to export data into.
  dataset_id | The identifier of the dataset containing the attribute.
  attribute_name | The attribute to be exported.
  binary_order | 99 - export data as text. 1 - export data as binary Native Order. 2 - export data as binary Little Endian. 3 - export data as binary Big Endian.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5export_dataset()

synchronized native void H5export_dataset | ( | String | file_export_name,
|  | long | file_id,
|  | String | object_path,
|  | int | binary_order ) throws HDF5LibraryException
| static

H5export_dataset is a utility function to save data in a file.

Parameters

  file_export_name | The file name to export data into.
  file_id | The identifier of the HDF5 file containing the dataset.
  object_path | The full path of the dataset to be exported.
  binary_order | 99 - export data as text. 1 - export data as binary Native Order. 2 - export data as binary Little Endian. 3 - export data as binary Big Endian.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5garbage_collect()

synchronized native int H5garbage_collect | ( |  | ) | throws HDF5LibraryException
| static

H5garbage_collect collects on all free-lists of all types.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5get_libversion()

synchronized native int H5get_libversion | ( | int[] | libversion | ) | throws HDF5LibraryException
| static

H5get_libversion retrieves the major, minor, and release numbers of the version of the HDF library which is linked to the application.

Parameters

  libversion | The version information of the HDF library.

         libversion[0] = The major version of the library.
         libversion[1] = The minor version of the library.
         libversion[2] = The release number of the library.

Returns
  a non-negative value if successful, along with the version information.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5open()

synchronized native int H5open | ( |  | ) | throws HDF5LibraryException
| static

H5open initialize the library.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5set_free_list_limits()

synchronized native int H5set_free_list_limits | ( | int | reg_global_lim,
|  | int | reg_list_lim,
|  | int | arr_global_lim,
|  | int | arr_list_lim,
|  | int | blk_global_lim,
|  | int | blk_list_lim ) throws HDF5LibraryException
| static

H5set_free_list_limits Sets limits on the different kinds of free lists. Setting a value of -1 for a limit means no limit of that type. These limits are global for the entire library. Each "global" limit only applies to free lists of that type, so if an application sets a limit of 1 MB on each of the global lists, up to 3 MB of total storage might be allocated (1MB on each of regular, array and block type lists).

The settings for block free lists are duplicated to factory free lists. Factory free list limits cannot be set independently currently.

Parameters

  reg_global_lim | The limit on all "regular" free list memory used
  reg_list_lim | The limit on memory used in each "regular" free list
  arr_global_lim | The limit on all "array" free list memory used
  arr_list_lim | The limit on memory used in each "array" free list
  blk_global_lim | The limit on all "block" free list memory used
  blk_list_lim | The limit on memory used in each "block" free list

Returns
  a non-negative value if successful, along with the version information.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ loadH5Lib()

void loadH5Lib | ( |  | ) |
| static

load native library

## Variable Documentation

## ◆ H5_LIBRARY_NAME_PROPERTY_KEY

final String H5_LIBRARY_NAME_PROPERTY_KEY = "hdf.hdf5lib.H5.loadLibraryName"
| static

add system property to load library by name from library path, via System.loadLibrary()

## ◆ H5PATH_PROPERTY_KEY

final String H5PATH_PROPERTY_KEY = "hdf.hdf5lib.H5.hdf5lib"
| static

add system property to load library by path

## ◆ LIB_VERSION

final int LIB_VERSION[] = {H5Version.MAJOR, H5Version.MINOR, H5Version.RELEASE}
| static

The version number of the HDF5 library:

- LIB_VERSION[0]: The major version of the library.
- LIB_VERSION[1]: The minor version of the library.
- LIB_VERSION[2]: The release number of the library.

NOTE: This version is automatically synchronized with H5public.h via the auto-generated H5Version class. To update the version, edit src/H5public.h (H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE). Do NOT manually edit the version numbers.