V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
shuangyeying
V2EX  ›  macOS

请教一个 Matlab 和 Java 联合编程的问题?

  •  
  •   shuangyeying · 2018-10-19 11:34:23 +08:00 · 3921 次点击
    这是一个创建于 2235 天前的主题,其中的信息可能已经有所发展或是发生改变。

    macOS Mojave
    Matlab 2018a
    java version "1.8.0_144"

    按照官方文档配置了 Java 环境
    https://www.mathworks.com/help/compiler_sdk/java/configure-your-java-environment.html

    以下是我环境变量的配置

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
    
    export JAVA_LIBRARY_PATH=/Applications/MATLAB/MATLAB_Runtime/v94/runtime/maci64:/Applications/MATLAB/MATLAB_Runtime/v94/sys/os/maci64:/Applications/MATLAB/MATLAB_Runtime/v94/bin/maci64:/Applications/MATLAB/MATLAB_Runtime/v94/extern/bin/maci64
    
    export CLASSPATH=.:/Applications/MATLAB_R2018a.app/toolbox/javabuilder/jar/javabuilder.jar
    

    在 IDEA 中执行还是出错了

    Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.9.4.dylib on java.library.path.
    This library is typically installed along with MATLAB or the MATLAB Runtime. Its absence may indicate an issue with that installation or 
    the current path configuration, or a mismatch with the architecture of the Java interpreter on the path.
    MATLAB Runtime version this component is attempting to use: 9.4.
    Java interpreter architecture: maci64.
    

    大家有什么思路没有呀?谢谢!

    第 1 条附言  ·  2018-10-19 16:49:49 +08:00

    JAVA_LIBRARY_PATH 还是得换成DYLD_LIBRARY_PATH

    4 条回复    2018-10-21 11:11:23 +08:00
    shuangyeying
        1
    shuangyeying  
    OP
       2018-10-19 12:40:32 +08:00
    ```
    New versions of OS X enable system integrity protection per default. Meaning that setting the DYLD_LIBRARY_PATH and LD_LIBRARY_PATH will have no effects.

    I had this issue before in another context, but it looks like it's a common issue on other Node modules as well: oracle/node-oracledb#231
    ```
    不知道和 SIP 有关系么?
    shuangyeying
        2
    shuangyeying  
    OP
       2018-10-19 16:47:37 +08:00
    自问自答
    确实好坑啊,command+R 进入恢复模式,csrutil disable 关闭 SIP 之后就可以了。
    官方文档完全没有问题。
    shuangyeying
        3
    shuangyeying  
    OP
       2018-10-20 13:09:31 +08:00
    已经搞定,有需要的 v 友可以参考我的博客。
    [macOS Mojave 上 Matlab 2018a 与 Java 的联合编程]( https://streamelody.github.io/2018/10/mojave-matlab-2018a-java/)
    zhengnanlee
        4
    zhengnanlee  
       2018-10-21 11:11:23 +08:00 via iPhone
    感谢支持我司产品
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2559 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 10:24 · PVG 18:24 · LAX 02:24 · JFK 05:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.