How to use hdf5 for java in Eclipse?

Hi all,

I'm new in HDF5, and I am a Java, Ubungtu-32bit 11.4, Eclipse user. But I
can't run the java intro-examples on my computer.

I have downloaded the "hdf-java-2.7-bin.tar", and extracted it. Then, I add
all the jar Files in the "haf-java -> lib" to my Project.

Then I copy the example file "H5_CreateDataset.java" into my Project, but it
doesn't work!!! The Error are:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
ncsa.hdf.hdf5lib.HDF5Constants.H5_INDEX_UNKNOWN()I
  at ncsa.hdf.hdf5lib.HDF5Constants.H5_INDEX_UNKNOWN(Native Method)
  at ncsa.hdf.hdf5lib.HDF5Constants.<clinit>(HDF5Constants.java:40)
  at H5_CreateDataset.CreateDataset(H5_CreateDataset.java:21)
  at H5_CreateDataset.main(H5_CreateDataset.java:77)

That means here is wrong:
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC,
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);"

I can't create a file! Why???

Thanks!

Conny

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2979006.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Conny,

You need to add the HDF5 JNI library to your path.

In Eclipse, go to "Run" --> "Run Configurations...". Select the program to run and add
the path at VM arguments, e.g.

Add the path
-Djava.libary.path=G:\Projects\Java\hdf-java\native\hdf5lib

Or add the specific library
-Dncsa.hdf.hdf5lib.H5.hdf5lib=G:\Projects\Java\hdf-java\native\hdf5lib\jhdf5.dll

Thanks
--pc

···

On 5/24/2011 5:13 AM, blatoo wrote:

Hi all,

I'm new in HDF5, and I am a Java, Ubungtu-32bit 11.4, Eclipse user. But I
can't run the java intro-examples on my computer.

I have downloaded the "hdf-java-2.7-bin.tar", and extracted it. Then, I add
all the jar Files in the "haf-java -> lib" to my Project.

Then I copy the example file "H5_CreateDataset.java" into my Project, but it
doesn't work!!! The Error are:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
ncsa.hdf.hdf5lib.HDF5Constants.H5_INDEX_UNKNOWN()I
  at ncsa.hdf.hdf5lib.HDF5Constants.H5_INDEX_UNKNOWN(Native Method)
  at ncsa.hdf.hdf5lib.HDF5Constants.<clinit>(HDF5Constants.java:40)
  at H5_CreateDataset.CreateDataset(H5_CreateDataset.java:21)
  at H5_CreateDataset.main(H5_CreateDataset.java:77)

That means here is wrong:
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC,
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);"

I can't create a file! Why???

Thanks!

Conny

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2979006.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hi Peter,

I think, I have already add the hdf5 library:
In Eclipse: project right click -> properties -> Java Build Path ->
Librabies -> Add External Jars -> jhdf5.jar

Actually I have added all the JarFiles:

Then, I did just like what you said:

But I still got the same Error Message. :frowning: .... It's so weird...

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2979976.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi Conny,

Make sure that the .dll (for Windows) or .so (for linux) is at the
-Djava.library.path=/.....

Check your /home/.../hdf5-2.7/hdf-java/lib/$YOUR_PLATFORM folder.

Thanks
--pc

···

On 5/24/2011 9:16 AM, blatoo wrote:

Hi Peter,

I think, I have already add the hdf5 library:
In Eclipse: project right click -> properties -> Java Build Path ->
Librabies -> Add External Jars -> jhdf5.jar

Actually I have added all the JarFiles:
http://hdf-forum.184993.n3.nabble.com/file/n2979976/snapshot3.jpg

Then, I did just like what you said:
http://hdf-forum.184993.n3.nabble.com/file/n2979976/snapshot4.jpg

But I still got the same Error Message. :frowning: .... It's so weird...

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2979976.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hi Peter,

I have checked the folder, then I found in the folder
"/home/fatfox/collections/java/hdf5/hdf5-2.7/hdf-java/lib/linux" there are
"libjhdf.so" and "libjhdf5.so", so I changed the Path in the VM argument.

Now it looks like this:

but the Error is still the same. It reported me always the error
"HDF5Constants.H5_INDEX_UNKNOWN() line: not available [native method]"

Shall I do some other Installatoins before I use HDF5?

Thanks!

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2980211.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi Conny,

It is very strange. Try to use the HDFView installer, which includes all the components.
  http://www.hdfgroup.org/hdf-java-html/hdfview/index.html

Thanks
--pc

···

On 5/24/2011 10:11 AM, blatoo wrote:

Hi Peter,

I have checked the folder, then I found in the folder
"/home/fatfox/collections/java/hdf5/hdf5-2.7/hdf-java/lib/linux" there are
"libjhdf.so" and "libjhdf5.so", so I changed the Path in the VM argument.

Now it looks like this:
http://hdf-forum.184993.n3.nabble.com/file/n2980211/snapshot5.jpg

but the Error is still the same. It reported me always the error
"HDF5Constants.H5_INDEX_UNKNOWN() line: not available [native method]"

Shall I do some other Installatoins before I use HDF5?

Thanks!

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2980211.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hi Peter,

I installed the HDFView Installer, but it still the same Error. (I did the
same setting in Eclipse like above )

I think, it may be either a bug in the latest HDF Version or the examples
online are not updated. Because, if I use the old Version HDF, the
"H5_CreateFile.java" and "H5_CreateDataset.java" do works. (But
H5_ReadWrite.java has some errors, it can't be run.)

Thank you very much for the help! :smiley:

Conny

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p2981740.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Did you manage to solve the problem, Conny? I'm getting the same thing.

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p3046826.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hi amyzeta,

If you use also ubuntu, then install the hdf5 from the synaptic package
management. Old Verison hdf5 works on my computer now. :smiley:

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p3056291.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hii peopel..
I am facing the same problem..
it is not letting me create a file?

java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
  at java.lang.Runtime.loadLibrary0(Runtime.java:823)
  at java.lang.System.loadLibrary(System.java:1028)
  at ncsa.hdf.hdf5lib.H5.loadH5Lib(H5.java:347)
  at ncsa.hdf.hdf5lib.H5.<clinit>(H5.java:274)
  at ncsa.hdf.hdf5lib.HDF5Constants.<clinit>(HDF5Constants.java:28)
  at ncsa.hdf.object.h5.H5File.<init>(H5File.java:186)
  at ncsa.hdf.object.h5.H5File.<init>(H5File.java:123)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at java.lang.Class.newInstance0(Class.java:355)
  at java.lang.Class.newInstance(Class.java:308)
  at ncsa.hdf.object.FileFormat.<clinit>(FileFormat.java:210)
  at H5FileCreate.main(H5FileCreate.java:38)
Cannot find HDF5 FileFormat.

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p3789888.html
Sent from the hdf-forum mailing list archive at Nabble.com.

Hii people..
I am facing the same problem..
it is not letting me create a file?

java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
  at java.lang.Runtime.loadLibrary0(Runtime.java:823)
  at java.lang.System.loadLibrary(System.java:1028)
  at ncsa.hdf.hdf5lib.H5.loadH5Lib(H5.java:347)
  at ncsa.hdf.hdf5lib.H5.<clinit>(H5.java:274)
  at ncsa.hdf.hdf5lib.HDF5Constants.<clinit>(HDF5Constants.java:28)
  at ncsa.hdf.object.h5.H5File.<init>(H5File.java:186)
  at ncsa.hdf.object.h5.H5File.<init>(H5File.java:123)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at java.lang.Class.newInstance0(Class.java:355)
  at java.lang.Class.newInstance(Class.java:308)
  at ncsa.hdf.object.FileFormat.<clinit>(FileFormat.java:210)
  at H5FileCreate.main(H5FileCreate.java:38)
Cannot find HDF5 FileFormat.

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p3789894.html
Sent from the hdf-forum mailing list archive at Nabble.com.

you need to tell eclipse where the hdf5 library is. set something like this

-Dncsa.hdf.hdf5lib.H5.hdf5lib=G:\Projects\Java\hdf-java\native\hdf5lib\jhdf5.dll

at vm arguments under the run configure.

···

On 3/1/2012 3:32 AM, kuki wrote:

Hii peopel..
I am facing the same problem..
it is not letting me create a file?

java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path
  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
  at java.lang.Runtime.loadLibrary0(Runtime.java:823)
  at java.lang.System.loadLibrary(System.java:1028)
  at ncsa.hdf.hdf5lib.H5.loadH5Lib(H5.java:347)
  at ncsa.hdf.hdf5lib.H5.<clinit>(H5.java:274)
  at ncsa.hdf.hdf5lib.HDF5Constants.<clinit>(HDF5Constants.java:28)
  at ncsa.hdf.object.h5.H5File.<init>(H5File.java:186)
  at ncsa.hdf.object.h5.H5File.<init>(H5File.java:123)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at java.lang.Class.newInstance0(Class.java:355)
  at java.lang.Class.newInstance(Class.java:308)
  at ncsa.hdf.object.FileFormat.<clinit>(FileFormat.java:210)
  at H5FileCreate.main(H5FileCreate.java:38)
Cannot find HDF5 FileFormat.

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p3789888.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Thank you!
--pc

Thanks..Peter! it worked

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-use-hdf5-for-java-in-Eclipse-tp2979006p3792515.html
Sent from the hdf-forum mailing list archive at Nabble.com.

I had multiple issues with installation in C++ and Java, neither seem to figure.When I used the Java version I simply found the specified jar files on their website and imported them externally. Eclipse seems to possess no issue until I’m going to open the file (I have also linked the hdf5.dll), and that I received this error:

Exception in thread “main” java.lang.Could not initialize class ncsa.hdf.hdf5lib.HDF5Constants at ncsa.hdf.object.h5.H5File.(H5File.java:98) at ncsa.hdf.object.h5.H5File.(H5File.java:143) at hdf5_getters.hdf5_open_readonly(hdf5_getters.java:52) at hdf5_getters.main(hdf5_getters.java:564) at Main.main(Main.java:7)

I really think it’s just that I even have not properly installed the Java-hdf libraries, however, I’m unsure of the way to properly install them. I read abreast of using CMake to compile some binaries, however, when compiling CMake threw some unknown errors so I’m completely stuck. Please help with the right installation, I can provide more info if needed.
This can only possible with the help of my trainer, now I am doing an online java course: https://www.cetpainfotech.com/technology/java-training

That is really an old version of hdf-java, which is no longer updated. Can you use the latest version in the newly released HDFView3.1.2?

Allen