加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-15 22:58:16 所属栏目:安全 来源:网络整理
导读:我正在尝试使用带有 Java 1.6的 Eclipse Indigo插件在OS X上使用Shell脚本启动Eclipse RCP应用程序. OS的版本是10.11.3 脚本如下: #!/bin/bashDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" pwd )"app_cmd=""$DIR/../Resources/jre/Contents/Home/bin/ja
我正在尝试使用带有 Java 1.6的 Eclipse Indigo插件在OS X上使用Shell脚本启动Eclipse RCP应用程序. OS的版本是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)

可能是什么原因?

解决方法

看起来问题在于运行的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命令.希望这将使您能够确定该命令有什么问题,以及如何解决它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读