Unable to start Activemq using Java

188 views Asked by At

I am trying to start activemq on my Ubuntu machine. I am trying to start the service using Java. The below is my code:

Runtime rt=  Runtime.getRuntime();
rt.exec(new String[]{"/bin/sh", "-c", "cd /home/varkala/Srinivas /Prime360/softwares/apache-activemq-5.5.1/bin;./activemq start"});

I also tried to run the run.jar in the bin folder. But it did not work

rt.exec(new String[]{"/bin/sh", "-c", "cd /home/varkala/Srinivas /Prime360/softwares/apache-activemq-5.5.1/bin;java -jar run.jar start"});

These are the error logs:

  /bin/sh: 1: cd: can't cd to /home/varkala/Srinivas
    Can't open startup.sh

But when I open the terminal manually and execute the command , activemq starts. Is there something wrong with my code?

Update: Strangely, I tried to execute the cd command with another directory: /home/Varkala/Desktop .. the command is working fine.But for the above mentioned directory , I am getting error

1

There are 1 answers

0
srinivas chaitanya On

This may not be technically correct answer. Whenever I tried to copy the full path , I noticed there is a space between two folders of my path Srinivas and Prime360 .You can observe it in the first line of code in my question.For files in other locations like Desktop , I did not see that space while copying and pasting the full path in my program. All I did was , I renamed my folder from Srinivas to srinivas and surprisingly, it worked . I am using Ubuntu 16.04 LTS