@bljones thanks, I took the batch script and put it in my HDFView install folder D:\Programme\HDF_Group\HDFView\3.1.0\
. I copied the H5ObjectEx_G_Create.java example from your answer to the same folder and simply executed the batch script
compile.bat H5ObjectEx_G_Create
This gives me the following error during execution of the line "%JAVABIN%\\java.exe" -cp "%INSTALLDIR%\\lib\\*; ...
:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
This is usually resolved by adding the dependency to slf4j-simple
or slf4j-api
to my java project. However, it seems to not find it in the library folder. But it is there, I did not make any changes to the installation folder of HDFView. -cp
should set the classpath. When I echo "%INSTALLDIR%\\lib\\*;%INSTALLDIR%"
and -Djava.library.path="%INSTALLDIR%\\lib"
I get
"d:\Programme\HDF_Group\HDFView\3.1.0\\lib\\*;d:\Programme\HDF_Group\HDFView\3.1.0"
-Djava.library.path="d:\Programme\HDF_Group\HDFView\3.1.0\\lib"
When I enter d:\Programme\HDF_Group\HDFView\3.1.0\\lib\\
into windows explorer I get an error that the path does not exist. However, when replacing all \\
with \
in the batch script I still get the same error. But that also should’t matter as windows ignores the second backslash anyways, except in the beginning of the path.
I checked the privileges. I do have read and execution rights on the whole HDFView install folder. I also tried with my admin account. Same result.
I noticed you use OpenJDK
. I currently still am on Java SE JDK. But I do not suppose this should be a problem, especially as you deliver the JRE
and the script executes your jre tools.
Ok, I got it working. I had to add %INSTALLDIR%\\lib\\extra\\slf4j-simple-1.7.25.jar
to the CLASSPATH
. The execution command now looks like this:
"%JAVABIN%\\java.exe" -cp "%INSTALLDIR%\\lib\\extra\\slf4j-simple-1.7.25.jar;%INSTALLDIR%\\lib\\*;%INSTALLDIR%" -Djava.library.path="%INSTALLDIR%\\lib" "%1%" dummy.h5
Ok, I finally came a step forward. The difference between your batch script and executing my code from within the build process in my IDE is setting the classpath -cp
.
So I wrote a very simple script
package org.test.hdf5objecttest;
import hdf.object.FileFormat;
import hdf.object.h5.H5File;
public class HDF5ObjectTest {
public static void main(String args[]) throws Exception {
try {
System.load("D:/Programme/HDF_Group/HDFView/3.1.0/lib/hdf5_java.dll");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5);
H5File file = (H5File) fileFormat.createFile("test.h5", FileFormat.FILE_CREATE_DELETE);
System.out.println("file: " + file);
}
}
This gives the same error as above java.lang.UnsatisfiedLinkError: D:\Programme\HDF_Group\HDFView\3.1.0\lib\hdf5_java.dll: The specified procedure could not be found
. So I image a procedure or call inside hdf5_java.dll
is missing. So, I first checked if there are other versions of the library in the PATH
. I had a version of Visit and netCDF that came with an old version of the hdf5 libraries. I removed them from the PATH
and got:
>where hdf5.dll
D:\Programme\HDF_Group\HDFView\3.1.0\lib\hdf5.dll
>where hdf5_java.dll
D:\Programme\HDF_Group\HDFView\3.1.0\lib\hdf5_java.dll
As there where no more possible confilicts, I tried loading libraries to find the ones that are missing. And loading hdf5.dll
did the trick.
package org.test.hdf5objecttest;
import hdf.object.FileFormat;
import hdf.object.h5.H5File;
public class HDF5ObjectTest {
public static void main(String args[]) throws Exception {
// WITHOUT THIS LOADING hdf_java.dll GIVES AN UnsatisfiedLinkError
try {
System.load("D:/Programme/HDF_Group/HDFView/3.1.0/lib/hdf5.dll");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
try {
System.load("D:/Programme/HDF_Group/HDFView/3.1.0/lib/hdf5_java.dll");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5);
H5File file = (H5File) fileFormat.createFile("test.h5", FileFormat.FILE_CREATE_DELETE);
System.out.println("file: " + file);
}
}
Now I ask myself, isn’t that something that should happen in the H5.java loadH5Lib();
method?