How to use HDF5 in Windows Java project with NetBeans

点点圈 提交于 2019-12-13 19:31:40

问题


I have a simple Java project and I have to write some data to a HDF5 file. I use Netbeans under Windows. Normally, I build libraries from the respective jar-files. So much for my knowledge how to do things ;)

I downloaded and installed the binaries from the hdf5 download page. But what comes next? I had a look at HDF5-Java support page but did not get any clue what to do to integrate HDF5 in my JavaApplication.

P.S.: I found sis-jhdf5 but I did not get it running as well. I also found some older sites explaining the compilation of HDF under windows and a thread for OS_X but that did not help me either.

There are so many different pages trying to explain this matter and I somehow lost the overview. May someone help me, please? A higher level of detail in the explanation would be appreciated ;)


回答1:


If you are not obliged to use a specific Java HDF5 library, you may want to have a look at HDFql which greatly simplify how HDF5 files are handled. This tool can be used in NetBeans IDE (8.2) as follows:

  1. Download HDFql from http://www.hdfql.com/#download and unzip it.

  2. Open NetBeans.

  3. Select menu option File > New Project (a dialog titled New Project should pop-up).

  4. Inside dialog New Project:

    4.1. Select Java for the category and Java Application for the project.

    4.2. Press button Next.

    4.3. Specify a name for the project and its location.

    4.4. Press button Finish.

  5. Select menu option Run > Set Project Configuration > Customize (a dialog titled Project Properties - ... should pop-up).

  6. Inside dialog Project Properties - ...:

    6.1. On the left side of the dialog, select Sources for the category, and after:

    6.1.1. Press button Add Folder... in the Source Packages Folders (a dialog titled Add Source Folder should pop-up):

    6.1.1.1. Inside dialog Add Source Folder, select the folder where the HDFql Java wrapper was unzipped in step 1. Example: c:\hdfql-2.0.0\wrapper\java.

    6.2. On the left side of the dialog, select Run for the category, and after:

    6.2.1 On the VM Options field, insert -Djava.library.path=c:\hdfql-2.0.0\wrapper\java\as\hdfql.

The NetBeans project is now properly configured to use HDFql. Now, if you run the following Java program (as an example):

import as.hdfql.*;

public class Test
{

    public static void main(String[] args)
    {
        // create an HDF5 file named "test.h5"
        HDFql.execute("CREATE FILE test.h5");
    }
}

An HDF5 file named test.h5 will be created in the folder where this program ran.



来源:https://stackoverflow.com/questions/49178400/how-to-use-hdf5-in-windows-java-project-with-netbeans

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!