Results 1 to 3 of 3
  1. #1
    Apotekarnes is offline Member
    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Default System call from within JAVA doesn't work.

    Hello everybody,

    I have a weird problem:

    I'd like to launch rhe program "bowtie2-build", which is included in my PATH variable, from within a JAVA-program via system call on my MAC.

    This is the what I did:

    Java Code:
    Runtime r = Runtime.getRuntime();
    r.exec("bowtie2-build /Users/ralf/Documents/results/test/example.fasta /Users/ralf/Documents/results/test/example");

    Some folders should be generated. But nothing happens. My Java-program does not proceed after the r.exec.

    The statement

    r.exec("mkdir /Users/ralf/Documents/results/test/hallo");

    works without a problem. The folder is generated.

    If I let Java print the call content, copy it and paste in the MAC terminal, it works as well.

    Is this a matter of escaping some characters?

    I also tried:
    Java Code:
    String[] args = new String[] {"'bowtie2-build'", jTextField2.getText(), path};
    System.out.println(args);
    Process p = r.exec(args);

    Without success...

    Any ideas?


    Best regards,
    Apotekarnes

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,913
    Rep Power
    5

    Default Re: System call from within JAVA doesn't work.

    As I read the API, it says that Runtime.exec will execute System commands (of which mkdir is one). I do not believe that applies to your situation. However, not having used the capability myself, I could be mistaken.

    Edit: I was clearly mistaken. On Windows 7 r.exec("notepad.exe") worked just fine. What is the nature of the program you are trying to run?

    Regards,
    Jim
    Last edited by jim829; 10-16-2013 at 05:04 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: System call from within JAVA doesn't work.

    Google:

    When Runtime.exec() won't
    Pitfalls of Runtime.exec()

Similar Threads

  1. Replies: 13
    Last Post: 10-04-2012, 08:45 PM
  2. Java Swing - JLabel setText() doesn't work
    By Zyril in forum New To Java
    Replies: 6
    Last Post: 07-29-2012, 10:51 PM
  3. Replies: 3
    Last Post: 01-05-2011, 08:29 AM
  4. System call with java 3
    By mike_ledis in forum New To Java
    Replies: 1
    Last Post: 03-26-2010, 07:51 PM
  5. System call with java
    By mike_ledis in forum Advanced Java
    Replies: 5
    Last Post: 03-26-2010, 12:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •