Page tree

 HDF-Java wrappers are provided for users who wish to compile HDF5 and HDF4 applications in Java. They are the native interfaces for Java HDF (JHI) and Java HDF5 (JHI5) that consist of the Java classes and C interface libraries.

These wrappers:

  • use 64-bit object identifiers.
  • can be obtained by BUILDING HDF5-1.10 and/or HDF 4.2.12+.
  • DO NOT INCLUDE the HDF-Java Object package.  (See HDFView for the object package.)

The HDF-Java wrappers that use 32-bit object identifiers (for HDF5-1.8) are only available from the old support web site.

Building the Wrappers

The HDF-Java wrappers can be built when compiling HDF5-1.10 and HDF4 (versions 4.2.12 and above) with the following options:

  • Autotools: ./configure --enable-java
  • CMake Option: HDF5_BUILD_JAVA:BOOL=ON (for HDF5),  HDF4_BUILD_JAVA:BOOL=ON (for HDF4)

Documentation

Compiling an Application

To compile an application you must set the following environment variables:

  • CLASSPATH: path to HDF-Java jar files
  • LD_LIBRARY_PATH: path to HDF-Java lib directory

A simple shell script or batch file can be created to compile applications. See the example script below.

To use this script you must add the correct path to the following variables:

  • HDFJAVA_HOME: Path to the HDF-Java binaries
  • JAVAPATH: Path to Java

When compiling with the script, leave off the application extension. For example if the script is called "runlin.sh", you would type the following to compile "program.java":

   ./runlin.sh program

Example Compile Script (Unix):

#!/bin/sh

export HDFJAVA_HOME=
export JAVAPATH=

######################################################

CPATH=$HDFJAVA_HOME"/lib/*"
export CLASSPATH=$CPATH":"$CLASSPATH
export LD_LIBRARY_PATH=$HDFJAVA_HOME"/lib"
echo $CLASSPATH

$JAVAPATH/javac  $1.java
$JAVAPATH/java -Xmx1G  -Djava.library.path=$HDFJAVA_HOME"/lib" $1 dummy.h5

Example Programs

HDF-Java applications can be found on the HDF5 Examples by API page, as well as in the source code.

If running these examples individually you must comment out this line at the top of the application:

   package examples....


--- Last Modified: October 25, 2018 | 08:05 AM