Results 1 to 5 of 5
  1. #1
    Smila is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default Execute Processing file from within Java

    Hi everyone,

    I have written this code to open and run a Processing (.pde file) sketch. So far, it opens the sketch, but it does not run it. The Processing keyboard shortcut for running a sketch is ⌘R. Any suggestions how I can get Java to run the sketch?

    Cheers!!

    This is my code:


    package javaapplication;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class max {

    private static Process child1;

    public static void main (String[] args) throws IOException {
    String s;
    try {
    Process p = Runtime.getRuntime().exec(
    "/usr/bin/open file:///Users/Documents/InteractiveSystem/processingfile/processingfile.pde");
    BufferedReader err = new BufferedReader (
    new InputStreamReader (p.getErrorStream()));
    while ((s = err.readLine()) != null) {
    System.out.println(s);
    }
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    try{
    String command = "⌘R";
    child1 = Runtime.getRuntime().exec(command);
    command = "⌘R";
    child1 = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    }
    }

    void RunProcess(){
    start();
    }

    private void start() {
    // TODO Auto-generated method stub

    }
    public void run() {
    try{
    Process run = Runtime.getRuntime().exec("/usr/bin/run file:///Users/Documents/InteractiveSystem/processingfile/processingfile.pde");
    }
    catch(Exception ex){
    char[] s = null;
    System.out.println(s);
    }
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,304
    Rep Power
    20

    Default Re: Execute Processing file from within Java

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    sabre150 is offline Member
    Join Date
    Jul 2012
    Location
    Earth
    Posts
    75
    Rep Power
    0

    Default Re: Execute Processing file from within Java

    'Processing' is written in Java. The FAQ for 'Processing' indicates that one can execute it directly from Java though the link seems to be broken.

  4. #4
    gowthamgutha is offline Member
    Join Date
    Sep 2012
    Location
    Guntur, India
    Posts
    27
    Rep Power
    0

    Default Re: Execute Processing file from within Java

    You can use the java.awt.Desktop class.

    try
    {
    Desktop d=Desktop.getDesktop();
    d.open(new File("mypde.pde"));
    }catch(Exception e){}
    More at, [Moderator edit: Blog spam removed]
    Last edited by DarrylBurke; 10-04-2012 at 03:49 PM.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,304
    Rep Power
    20

    Default Re: Execute Processing file from within Java

    Quote Originally Posted by gowthamgutha View Post
    try
    {
    Desktop d=Desktop.getDesktop();
    d.open(new File("mypde.pde"));
    }catch(Exception e){}
    There's already a link to the BB Code FAQ in this thread. Please go through it and don't post unformatted code again.

    Also, your response here, like some others you have posted today, doesn't answer the question.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 04-27-2012, 07:14 AM
  2. Execute .jar file within java program?
    By JHumphr in forum Advanced Java
    Replies: 2
    Last Post: 06-07-2011, 06:19 PM
  3. Delimited file processing
    By lottalava in forum Advanced Java
    Replies: 7
    Last Post: 06-17-2010, 11:19 PM
  4. Replies: 1
    Last Post: 11-03-2009, 07:07 AM
  5. Execute Jar file
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:13 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
  •