无法在eclipse或转换为jar后启动OSGI框架



我正在开发一个OSGI春分启动器,它应该启动OSGI框架和春分控制台。我已经在一个名为插件的文件夹中添加了五个jar,作为类路径/buildpath的一部分,但仍然无法执行。

下面是在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_path .10.0.v20140606-1445.jar -console

但是上面的代码在我的代码中失败了,如下所示

public static void main(String[] args) {

String command ="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_1 .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 plugin/org.eclipse.osgi_3.10.1.v20140909-1633.jar

这两个命令(在Linux控制台中成功执行的命令和在代码中失败的命令)略有不同。第一个使用

-jar org.eclipse.osgi_3.10.0.v20140606-1445.jar

而在第二个

-jar plugin/org.eclipse.osgi_3.10.1.v20140909-1633.jar

因为你得到的错误信息说它不能访问plugin/org.eclipse.osgi_3.10.1.v20140909-1633.jar,我假设这个jar文件不存在,这就是为什么你的命令失败。

最新更新