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

    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};
    Process p = r.exec(args);

    Without success...

    Any ideas?

    Best regards,

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    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?

    Last edited by jim829; 10-16-2013 at 04: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
    Rep Power

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


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

Similar Threads

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

Posting Permissions

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