我制作了一个.app文件夹,其中包含一个Java应用程序和一个JRE。我使用app-bundle-maven插件创建了.app文件夹。
我的Java应用程序从ISO映像创建一个.dmg文件,并通过启动hdiutil作为子进程来执行此操作。
这在从命令行或集成开发环境运行时没有任何问题,但在从.app文件夹启动时会失败。
ProcessBuilder抛出找不到/usr/bin/hdiutil的IOException。
我的问题是:.app文件夹像沙箱吗?Info.plist文件中是否有能够覆盖沙箱行为的设置?
Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>JavaAppLauncher</string>
<key>CFBundleIconFile</key>
<string>usbboot.icns</string>
<key>CFBundleIdentifier</key>
<string>de.bamamoto.mactools.usbboot.USBBoot</string>
<key>CFBundleDisplayName</key>
<string>USBBoot</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>USBBoot</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0-SNAPSHOT</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSHighResolutionCapable</key>
<true/>
<key>JVMRuntime</key>
<string>JRE</string>
<key>JVMMainClassName</key>
<string>de.bamamoto.mactools.usbboot.USBBoot</string>
<key>JVMClassPaths</key>
<array>
<string>de/bamamoto/webmusic/USBBoot/1.0-SNAPSHOT/USBBoot-1.0-SNAPSHOT.jar</string>
</array>
<key>JVMVersion</key>
<string>1.6+</string>
<key>JVMOptions</key>
<array>
<string>-Dapple.laf.useScreenMenuBar=true</string>
<string>-Xdock:name=USBBoot</string>
<string>-Djava.util.Arrays.useLegacyMergeSort=true</string>
</array>
<key>JVMArguments</key>
<array/>
<key>LauncherWorkingDirectory</key>
<string>$APP_ROOT</string>
</dict>
</plist>发布于 2016-01-05 04:22:48
我找到了这个问题的解决方案。位于JREs lib文件夹中的一个名为jspawnhelper的文件在复制操作期间丢失了他的执行标志。使用ProcessBuilder.start()或Runtime.exec()方法调用时需要此文件。
抛出的找不到可执行文件的IOException具有误导性。在此文件上设置了execute标志后,一切都按预期运行。
https://stackoverflow.com/questions/34482325
复制相似问题