Hdf5 in the maven project

I am trying to import hdf.hdf5lib.H5 into my maven project in NetBeans. It has this as an import string

import hdf.hdf5lib.H5; 

as suggested here: https://support.hdfgroup.org/products/java/JNI3/jhi5/index.html

However, this excludes this exception:

 java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Uncompilable source code - package hdf.hdf5lib does not exist 

NetBeans already warned me about this by saying "packadge does not excist" in the import line. So I allowed "look for dependencies in Maven repositories." He finds something, and he adds this to my pom.xml:

 <dependency> <groupId>org.hdfgroup</groupId> <artifactId>hdf-java</artifactId> <version>2.6.1</version> <type>jar</type> </dependency> 

Unfortunately, it saves a warning in the import line "packadge is not excist" and an error exception. This addition to pom.xml seems to do nothing.

I'm new to all of this, so maybe the solution is obvious, but I can't find it. These questions are already dated between 2012 and 2014, but did not help me:

http://hdf-forum.184993.n3.nabble.com/maven-repository-for-java-release-td4026938.html

http://hdf-forum.184993.n3.nabble.com/HDF-Java-on-Maven-td4025772.html

add hdf5 libs (java and C ++) to the maven public repository?

As suggested by ddarellis, this may be a version issue. There seem to be two options.

  • HDF Java 3.3.2 and HDF5-1.8.19 (HDFView version 2.14)
  • Java HDF Object Package 3.0.0 and HDF5-1.10

I will try both, but the maven suggestion to use Java 2.6.1 HDF is incorrect.

This post was useful for adding jarhdf5-3.3.2.jar depending.

https://forums.netbeans.org/post-62903.html#62903

  • In the Maven project, open the Add Dependency dialog
  • Compose some groupId, artifactId and version and fill them out, OK.
  • The dependency will be added to pom.xml and will appear in the "Libraries" section of the maven project node
  • Right-click Lib node and "manually install the artifact", fill in the path to the bank. The jar must be installed on the local Maven repository with the coordinates entered in step 2).

So, I installed HDF5 1.8.19 HDFView2.14 and added jarhdf5-3.3.2 to the dependencies. However, I get this error when I try to run:

 Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at hdf.hdf5lib.H5.<clinit>(H5.java:230) 
+7
java maven netbeans hdf5
source share
2 answers

In the link you posted, you can see this at the top:

Very important change: Version 3.0 (and higher) of JHI5 packages all HDF libraries are called "hdf.hd5flib", please note that "ncsa" is deleted. The source code that used earlier versions of JHI5 should be modified to reflect this new implementation.

What does this mean if you are using a lower version of the library from v3.0 that you are (v2.6.1), you must include ncsa .hdf.hdf5lib.H5 in front of the package name.

You can find manuals here.

+5
source share

The link you are linking to contains obsolete examples, you should use these examples .

As ddarellis pointed out , the correct package is:

 ncsa.hdf.hdf5lib 

Here is a working example of opening an HDF5 file:

 import ncsa.hdf.hdf5lib.H5; import ncsa.hdf.hdf5lib.HDF5Constants; import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; public class Foo { public void openHdf5File() { int flags = HDF5Constants.H5P_DEFAULT; int access = HDF5Constants.H5F_ACC_RDWR; try { int file_id = H5.H5Fopen("myFile.hdf", flags, access); } catch (HDF5Exception ex) { System.err.println("Failed to open HDF5 file"); } } } 

You have the correct maven dependency and the latter is available on maven central .

+5
source share

All Articles