-1

Iam developing an OSGI equinox launcher which should start the OSGI framework and equinox console.I have added the five jars in a folder called as plugin as a part of the classpath/buildpath but still iam unable to execute.

Below is the command which executes successfully on the linux console and opens the osgi> prompt on linux console.

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

But the above fails in my code which is as below

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_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);
        }
    }

The error is as below Here is the standard output of the command:

Here is the standard error of the command (if any):

Error: Unable to access jarfile plugin/org.eclipse.osgi_3.10.1.v20140909-1633.jar

chetan
  • 55
  • 10

1 Answers1

0

The two commands (the one that is executing successfully on the Linux console and the one that fails in your code) are slightly different. In the first one you use

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

while in the second

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

Since the error message you get says that it cannot access plugin/org.eclipse.osgi_3.10.1.v20140909-1633.jar I assume that this jar file does not exist which is why your command is failing.

Azzabi Haythem
  • 2,318
  • 7
  • 26
  • 32
Christina
  • 3,562
  • 3
  • 22
  • 32
  • Nope same problem even after i changed the jar !!! even though both the commands in the console and eclipse are same – chetan Jul 08 '15 at 09:20
  • I assume that since you have now changed the jar the error message has also changed accordingly, right? Can you check that both commands (console and eclipse) are the same? Alternatively you could try passing an absolute path for the jar to be certain that Eclipse is looking for it in the right place. – Christina Jul 08 '15 at 09:23
  • if i give absolute path and when i run it on eclipse and when i convert the project as jar and run it as java -jar X.jar i get the below output without osgi console **Here is the standard output of the command:** – chetan Jul 08 '15 at 09:40
  • @chetan I can't really see an output in your comment. Do you mean that you do not get any output? Do you get an error message in that case? – Christina Jul 09 '15 at 08:24