在OS X上无法启动Eclipse RCP应用程序

6

我正试图在OS X上使用Eclipse Indigo插件和Java 1.6通过Shell脚本启动Eclipse RCP应用程序。操作系统的版本是10.11.3。 脚本如下:

#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
app_cmd="\"$DIR/../Resources/jre/Contents/Home/bin/java\" 
-XstartOnFirstThread
-Xdock:name=GS\ Risk
-Xdock:icon=\"$DIR/../Resources/AppIcon.ico\"
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Dosgi.console.enable.builtin=true
-jar \"$DIR/../Resources/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar\"
-data @noDefault 
-Dfile.encoding=UTF-8 
-os macosx 
-ws cocoa 
-arch x86_64 
-nl en_US 
-consoleLog 
-console 
-showsplash
AppName"

runCommand() { 
    typeset cmnd="$*" 
    typeset ret_code
    echo cmnd=$cmnd 
    eval $cmnd 
    ret_code=$?
    case $ret_code in 
    0)   
        printf "[%s] exit OK." "$NAME"   
        ;; 
    23)   
        printf "[%s] requested a restart. Restarting..." "$NAME"   r
        unCommand "$cmnd"   
        ;; 
    *)
        printf "Error : [%d] when executing command: '$cmnd'" $ret_code   
        ;; 
    esac 
    printf "\n" 
    exit $ret_code 
}

runCommand "$app_cmd"

我收到了以下错误信息:
!SESSION Thu Feb 18 21:50:11 GMT+05:30 2016 ------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2016-02-18 21:50:11.660
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.RuntimeException: Could not find framework
    at org.eclipse.equinox.launcher.Main.getBootPath(Main.java:978)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:557)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

什么可能是原因?

它一直报同样的错误,即使我更新了plist或ini文件,它仍然以某种方式使用系统vm。该应用程序需要使用特定的jre。 - Saptak Niyogi
尝试使用另一个工具解压您的文件,并检查您的路径、文件夹和文件名。来源:https://www.eclipse.org/forums/index.php/t/24093/ - Daniel
没有zip文件。我正在尝试创建一个安装程序。 - Saptak Niyogi
1
你是否已经阅读并理解了 Bash FAQ 50 - miken32
我相信这个其他的线程会回答你的问题。 https://dev59.com/QGnWa4cB1Zd3GeqP0nF_ - Brian Mc
1个回答

2
看起来问题出在运行Java命令的代码上,而不是Bash代码本身,但Bash代码存在一些问题,使得调试变得困难。其中一个问题是使用字符串来存储命令、选项和参数。这通常是个坏主意,因为它很难避免路径名扩展(globbing)和单词拆分所带来的问题。另一个问题是使用eval,最好避免使用,而且很少必要。下面是稍微修改过的代码,它使用数组来存储命令,而不使用eval:
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

app_cmd_parts=(
    "$DIR/../Resources/jre/Contents/Home/bin/java"
    -XstartOnFirstThread
    -Xdock:name='GS Risk'
    -Xdock:icon="$DIR/../Resources/AppIcon.ico"
    -Dorg.eclipse.swt.internal.carbon.smallFonts
    -Dosgi.console.enable.builtin=true
    -jar "$DIR/../Resources/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar"
    -data @noDefault
    -Dfile.encoding=UTF-8
    -os macosx
    -ws cocoa
    -arch x86_64
    -nl en_US
    -consoleLog
    -console
    -showsplash
    AppName
)

runCommand() {
    typeset cmd_parts=( "$@" )
    typeset ret_code
    printf 'cmd_parts=('
    printf ' %q' "${cmd_parts[@]}"
    printf ' )\n'
    "${cmd_parts[@]}"
    ret_code=$?
    case $ret_code in
    0)
        printf "[%s] exit OK." "$NAME"
        ;;
    23)
        printf "[%s] requested a restart. Restarting..." "$NAME" runCommand "${cmd_parts[*]}"
        ;;
    *)
        printf "Error : [%d] when executing command: '${cmd_parts[*]}'" $ret_code
        ;;
    esac
    printf "\n"
    exit $ret_code
}

runCommand "${app_cmd_parts[@]}"

这应该更容易调试。使用bash -x运行它,以查看它正在做什么。复制并粘贴cmd_parts =(...)输出中括号之间的文本以重新运行程序运行的Java命令。希望这将使您确定命令有何问题以及如何修复它。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接