Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hdf5 in maven project

I'm trying to import hdf.hdf5lib.H5 into my maven project in NetBeans. It has this as import line

import hdf.hdf5lib.H5;

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

However, it throws this exception:

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

NetBeans already warned me about it by saying at the import line "packadge does not excist". So I let it "search dependencies at Maven repositories". It does find something and it 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 keeps the warning at the import line "packadge does not excist" and the error exception. It seems this addition to the pom.xml does nothing.

I am a beginner in all of this, so maybe the solution is obvious, but I cannot find it. These questions already date back to between 2012 and 2014, but didn't 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 & c++) to public maven repository?

How to use HDF5 in Windows Java project with NetBeans

Getting Started with hdf5 Java library

As suggested by ddarellis this might be a version problem. It seems there are 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'll try both, but the suggestion from maven to use HDF Java 2.6.1 is wrong.

This post was helpfull for adding jarhdf5-3.3.2.jar to the dependencies.

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

  1. In Maven project open "Add dependency" dialog
  2. Make up some groupId, artifactId and version and fill them, OK.
  3. Dependency will be added to the pom.xml and will appear under "Libraries" node of maven project
  4. Right-click Lib node and "manually install artifact", fill the path to the jar Jar should be installed to local Maven repo with coordinates entered in step 2).

Ok, 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)
like image 310
Gelliant Avatar asked Dec 11 '17 12:12

Gelliant


1 Answers

At the link you have posted you can see this at the top:

Very Important Change: Version 3.0 (and above) of the JHI5 packages all HDF library calls as "hdf.hd5flib", note that the "ncsa" has been removed. Source code which used earlier versions of the JHI5 should be changed to reflect this new implementation.

What this means is if you use lower library version from v3.0 which you are (v2.6.1) you have to include ncsa.hdf.hdf5lib.H5 in-front of the package name.

You can find tutorials here.

like image 194
ddarellis Avatar answered Oct 30 '22 22:10

ddarellis