Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Started with hdf5 Java library

Tags:

java

hdf5

I am learning HDF5 with jhdf5.

I am working on MAC OS_X.

  1. brew install hdf5

This installs hdf5-1.10 in /usr/local/Cellar/hdf5

  1. Copy this file and put it in gradle project.

https://support.hdfgroup.org/ftp/HDF5/hdf-java/hdf-java-examples/jnative/h5/HDF5FileCreate.java

This is the most basic java example file.

  1. Add this dependency in gradle

    compile group: 'org.hdfgroup', name: 'hdf-java', version: '2.6.1'

  2. Update package import statements by adding ncsa in front.

  3. Run it. And I got this error java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path

This is expected because jhdf5 according to my knowledge is just a wrapper calling native functions.

So I need to add something to ncsa.hdf.hdf5lib.H5.hdf5lib in the system setting.

I am not sure which library to add and where to find them.

I found a few examples online but all are in Windows, hence, the names are and paths are not really similar.

like image 540
william Avatar asked Jun 01 '26 13:06

william


1 Answers

I found it after trying a few times.

  1. Go to https://support.hdfgroup.org/products/java/release/cmakebuild.html and install CMake-hdfjava-.

    NOTE: might need to install CMake if it is not done before.

  2. After installing it (by running the script), go to build directory. Unzip the zip file mentioned in the webpage.

  3. add this when running the java file from IDEs, example:

    -Djava.library.path=/Users/wphyo/Projects/LSMD/CMake-hdfjava-3.3.2/build/HDFJava-3.3.2-Darwin/HDF_Group/HDFJava/3.3.2/lib

    Alternatively, we can also use the shell script provided in the web page to run too.

like image 158
william Avatar answered Jun 03 '26 01:06

william



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!