java.lang.UnsatisfiedLinkError:java.library.path 中没有 jhdf5

Posted

技术标签:

【中文标题】java.lang.UnsatisfiedLinkError:java.library.path 中没有 jhdf5【英文标题】:java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path 【发布时间】:2017-06-27 13:19:45 【问题描述】:

我在运行保存和加载 h5 文件的 Scala Saddle 1.3.4 应用程序时遇到上述错误。

我已经尝试过配置以下(Win64)但没有成功:

-Djava.library.path=C:\Dev\Tools\HDF5\1.10.0\lib\ -Djava.library.path=C:\Dev\Tools\HDF5\1.10.0\lib\jarhdf5-1.10.0.jar -Dnative.libpath.jhdf5=C:\Dev\Tools\HDF5\1.10.0\lib\hdf5_java.dll -Dnative.libpath=C:\Dev\Tools\HDF5\1.10.0\lib\

以及其他一些替代方案,但我仍然得到堆栈跟踪:

java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    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 org.saddle.io.H5Store$$anonfun$createFile$1.apply$mcI$sp(H5Store.scala:291)
    at org.saddle.io.H5Store$$anonfun$createFile$1.apply(H5Store.scala:290)
    at org.saddle.io.H5Store$$anonfun$createFile$1.apply(H5Store.scala:290)
    at org.saddle.io.H5Store$.org$saddle$io$H5Store$$withMonitor(H5Store.scala:49)
    at org.saddle.io.H5Store$.createFile(H5Store.scala:290)
    at org.saddle.io.H5Store$.org$saddle$io$H5Store$$writePandasFrame(H5Store.scala:1029)
    at org.saddle.io.H5Store$$anonfun$writeFrame$1.apply$mcI$sp(H5Store.scala:210)
    at org.saddle.io.H5Store$$anonfun$writeFrame$1.apply(H5Store.scala:210)
    at org.saddle.io.H5Store$$anonfun$writeFrame$1.apply(H5Store.scala:210)
    at org.saddle.io.H5Store$.org$saddle$io$H5Store$$withMonitor(H5Store.scala:49)
    at org.saddle.io.H5Store$.writeFrame(H5Store.scala:209)
    at org.saddle.io.H5Implicits$$anon$1.writeHdfFile(H5Implicits.scala:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.juliusbaer.example.Main$.main(Main.scala:30)
    at com.juliusbaer.example.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Exception in thread "main" java.lang.UnsatisfiedLinkError: ncsa.hdf.hdf5lib.H5.H5dont_atexit()I
    at ncsa.hdf.hdf5lib.H5.H5dont_atexit(Native Method)
    at ncsa.hdf.hdf5lib.H5.loadH5Lib(H5.java:365)
    at ncsa.hdf.hdf5lib.H5.<clinit>(H5.java:274)
    at ncsa.hdf.hdf5lib.HDF5Constants.<clinit>(HDF5Constants.java:28)
    at org.saddle.io.H5Store$$anonfun$createFile$1.apply$mcI$sp(H5Store.scala:291)
    at org.saddle.io.H5Store$$anonfun$createFile$1.apply(H5Store.scala:290)
    at org.saddle.io.H5Store$$anonfun$createFile$1.apply(H5Store.scala:290)
    at org.saddle.io.H5Store$.org$saddle$io$H5Store$$withMonitor(H5Store.scala:49)
    at org.saddle.io.H5Store$.createFile(H5Store.scala:290)
    at org.saddle.io.H5Store$.org$saddle$io$H5Store$$writePandasFrame(H5Store.scala:1029)
    at org.saddle.io.H5Store$$anonfun$writeFrame$1.apply$mcI$sp(H5Store.scala:210)
    at org.saddle.io.H5Store$$anonfun$writeFrame$1.apply(H5Store.scala:210)
    at org.saddle.io.H5Store$$anonfun$writeFrame$1.apply(H5Store.scala:210)
    at org.saddle.io.H5Store$.org$saddle$io$H5Store$$withMonitor(H5Store.scala:49)
    at org.saddle.io.H5Store$.writeFrame(H5Store.scala:209)
    at org.saddle.io.H5Implicits$$anon$1.writeHdfFile(H5Implicits.scala:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.juliusbaer.example.Main$.main(Main.scala:30)
    at com.juliusbaer.example.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

【问题讨论】:

我通过下载 HDFView 然后在路径 -Dncsa.hdf.hdf5lib.H5.hdf5lib=C:\HDFView\2.13.0\lib\jhdf5.dll 中添加以下内容解决了这个问题 你在哪里添加这个? 对于那些尝试使用 HDFView 的人,我通过在路径环境变量中添加“/HDFViewApp-3.1.2-win10_64-vs16\HDFView\app\bin”来解决这个问题,然后重新启动 cmd 【参考方案1】:

我在 Windows 操作系统上启动二进制文件时遇到了同样的问题。启动HDFView.exe 后会弹出一个命令窗口,然后再次关闭。

通过 CLI 启动它后,我看到了您提到的错误:

java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path

我用上面的@kaladin anwser 解决了这个问题:我将路径&lt;path to app&gt;/HDFViewApp-3.1.2-win10_64-vs16\HDFView\app\bin 添加到 PATH 系统环境变量中。保存后重启EXE文件,直接按预期运行!

【讨论】:

以上是关于java.lang.UnsatisfiedLinkError:java.library.path 中没有 jhdf5的主要内容,如果未能解决你的问题,请参考以下文章