Ok, I gave it another shot with HDFView 3.1.0. I figured some stuff out. I guess I mixed up something between the object package from HDFView and the Java stuff inside HDF5 itself. Unfortunately, most of the documentation is on the “old” JNI interface and not for the object package. It is really unfortunate that there are no examples in HDFView repository how to use the object package. Instead, the Java examples in the HDF5 repository are for the non-object package way.
My problem with HDF5Constants is resolved if you know that the HDF5Constants.java from HDF5 can be found in H5File, FileFormat.java and so on.
However, I still get an error. Here is what I did. I installed HDFView 3.1.0 to D:\Programme\HDF_Group\HDFView\3.1.0
. From the lib
folder in there, I than installed jarhdf5-1.10.5.jar
and hdfobject.jar
to my local Maven repository:
mvn install:install-file -Dfile=jarhdf5-1.10.5.jar -DgroupId=org.hdfgroup -DartifactId=jarhdf5 -Dversion=1.10.5 -Dpackaging=jar
mvn install:install-file -Dfile=hdfobject.jar -DgroupId=org.hdfgroup -DartifactId=hdfobject -Dversion=1.10.5 -Dpackaging=jar
I than created a small test project just to create a HDF5 file
package org.test.hdf5objecttest;
import hdf.object.FileFormat;
import hdf.object.h5.H5File;
public class HDF5ObjectTest {
public static void main(String args[]) {
H5File file = new H5File(
"test.h5"
,FileFormat.WRITE
);
}
}
with my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test</groupId>
<artifactId>HDF5ObjectTest</artifactId>
<version>0.0.0.1</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.hdfgroup</groupId>
<artifactId>hdfobject</artifactId>
<version>1.10.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hdfgroup</groupId>
<artifactId>jarhdf5</artifactId>
<version>1.10.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
</project>
I also added -Djava.library.path=D:\Programme\HDF_Group\HDFView\3.1.0\lib
to the VM options just to be on the safe side. I can build the test program, However, on execution I get
Exception in thread "main" java.lang.NoClassDefFoundError: hdf/hdflib/HDFException
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:332)
at hdf.object.FileFormat.<clinit>(FileFormat.java:208)
at org.test.hdf5objecttest.HDF5ObjectTest.main(HDF5ObjectTest.java:10)
Caused by: java.lang.ClassNotFoundException: hdf.hdflib.HDFException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
...
and I simply can not find a HDFException class in any of the repositories. HDF5Exception yes, HDFExpection no. I’ll attach the sample problem. I really am on the verge of giving up. maybe someone has a short hint and can point out what I am doing wring. Any clue would be much appreciated.
HDF5ObjectTest.rar (1.8 KB)