Results 1 to 4 of 4
  1. #1
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default java.io.IOException: CreateProcess: matlab error=2

    I'm using matlab it is call by a class what its name is "Engine"

    I'm working in linux and works fine, I want to know how can I do that with windows.
    I found on Internet a class call MatlabControl, that uses all .jar of matlab.
    But it gives to me problems when I try to create a matlab object
    Java Code:
     try {
                Process p = Runtime.getRuntime().exec("matlab");
            } catch (IOException ex) {
                ex.printStackTrace();
            }
    And this is the exception:
    Java Code:
    java.io.IOException: CreateProcess: matlab error=2
            at java.lang.ProcessImpl.create(Native Method)
            at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
            at java.lang.ProcessImpl.start(ProcessImpl.java:30)
            at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
            at java.lang.Runtime.exec(Runtime.java:591)
            at java.lang.Runtime.exec(Runtime.java:429)
            at java.lang.Runtime.exec(Runtime.java:326)
            at matlab.Main.main(Main.java:32)
    Can you help me?
    Last edited by Jack; 06-30-2007 at 02:39 AM.

  2. #2
    pgandle is offline Member
    Join Date
    Jun 2007
    Posts
    1
    Rep Power
    0

    Default solution from java world

    CreateProcess error=2, trying to open xml file
    When Runtime.exec() won't - Java World

    try {
    String[] cmd = new String[4];
    cmd[0] = "cmd.exe";
    cmd[1] = "/C";
    cmd[2] = "start";
    cmd[3] = "D:\\examples\\invoices\\2-1-20070625061706-ABC.xls";
    // cmd[3] = "will.xls";
    // cmd[3] = "mailto:";
    // cmd[3] = "a.html";
    // cmd[3] = "file:/c:/java/temp/a.html";

    Process process = Runtime.getRuntime().exec( cmd );
    } catch (IOException e) {
    e.printStackTrace();
    }

  3. #3
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    it works!!!
    thanks pgandle!

  4. #4
    Join Date
    Apr 2008
    Location
    India
    Posts
    4
    Rep Power
    0

    Default

    Could you please tell me what cmd[3] is standing for?
    cmd[0] is the executable file name I think ... but I ma not getting what cmd[3] is ?? is this for some logging purpose

Similar Threads

  1. error with import java.io.*
    By osval in forum New To Java
    Replies: 5
    Last Post: 05-13-2010, 06:03 PM
  2. Help, Integrate a Java with Matlab
    By toby in forum Advanced Java
    Replies: 2
    Last Post: 08-07-2008, 08:08 AM
  3. Replies: 1
    Last Post: 08-07-2007, 06:37 AM
  4. java.io.IOException: invalid header field
    By osval in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 12:09 AM
  5. Variable passing, Error: IOException
    By fernando in forum New To Java
    Replies: 3
    Last Post: 07-31-2007, 03:03 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
  •