【问题标题】:How to open mounted disk on mac through java program?如何通过java程序在mac上打开挂载的磁盘?
【发布时间】:2017-12-27 11:43:40
【问题描述】:

我正在下载一个 dmg 文件,然后尝试通过 java 代码自动打开安装程序。

我可以下载该文件,然后使用“hdiutil attach file.dmg”挂载它。

使用 URL 、输入流和输出流下载文件

安装 dmg: /usr/bin/hdiutil 附加文件.dmg

我无法打开这个安装的磁盘,以便安装程序进入前台。关于如何做到这一点有什么想法吗?

谢谢!

哈沙P

【问题讨论】:

  • Desktop.getDesktop().open("... .dmg"); 可能是个主意。

标签: java macos mount dmg


【解决方案1】:

执行open /Volumes/VolumeName,它会为它打开finder文件夹

如果需要,或者使用osascript 运行一个applescript,将finder 显式地带到前台:

property the_path : "/Volumes/MyMacDrive/Mani/WorkSpace/" set the_folder to (POSIX file the_path) as alias tell application "Finder" activate if window 1 exists then set target of window 1 to the_folder else reveal the_folder end if end tell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    • 2011-11-13
    • 2013-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多