我正在开发一个 OSGI equinox 启动器,它应该启动 OSGI 框架和 equinox 控制台。我已经在一个名为 plugin 的文件夹中添加了五个 jar 作为类路径/构建路径的一部分,但仍然无法执行。
以下是在 linux 控制台上成功执行并在 linux 控制台上打开 osgi> 提示符的命令。
java-Dosgi.bundles=org.eclipse.equinox.console_1.1.0.v20140131-1639.jar.@start,org.apache.felix.gogo.command_0.10.0.v201209301215.jar@start,org.apache.felix.gogo .runtime_0.10.0.v201209301036.jar@start,org.apache.felix.gogo.shell_0.10.0.v201212101605.jar@start -jar org.eclipse.osgi_3.10.0.v20140606-1445.jar -console
但是上面的代码在我的代码中失败了,如下所示
公共静态无效主要(字符串[]参数){
字符串命令="java-Dosgi.bundles=plugin/org.eclipse.equinox.console_1.1.0.v20140131-1639.jar@start,plugin/org.apache.felix.gogo.command_0.10.0.v201209301215.jar@start, plugin/org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar@start,plugin/org.apache.felix.gogo.shell_0.10.0.v201212101605.jar@start -jar plugin/org.eclipse.osgi_3.10.1 .v20140909-1633.jar -console";
        try {
            // using the Runtime exec method:
            Process p = Runtime.getRuntime().exec(command);
            BufferedReader stdInput = new BufferedReader(new
                 InputStreamReader(p.getInputStream()));
            BufferedReader stdError = new BufferedReader(new
                 InputStreamReader(p.getErrorStream()));
            // read the output from the command
            System.out.println("Here is the standard output of the command:\n");
            while ((s = stdInput.readLine()) != null) {
                System.out.println(s);
            }
            // read any errors from the attempted command
            System.out.println("Here is the standard error of the command (if any):\n");
            while ((s = stdError.readLine()) != null) {
                System.out.println(s);
            }
            System.exit(0);
        }
        catch (IOException e) {
            System.out.println("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
        }
    }
错误如下 这是命令的标准输出:
这是命令的标准错误(如果有):
错误:无法访问jarfile插件/org.eclipse.osgi_3.10.1.v20140909-1633.jar