Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4117210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:48:22+00:00 2026-05-20T22:48:22+00:00

referring to my previous question at Unable to perform any action before Process.Runtime.exec statement

  • 0

referring to my previous question at Unable to perform any action before Process.Runtime.exec statement line, I have changed my code into two part, a thread class CmdExec that has all code to execute an external program as below:

    public class CmdExec extends Thread
     {
     private String cmd;
     private File path;

      public CmdExec() {
      }

      public CmdExec(String cmd, File path) {
      this.cmd = cmd;
      this.path = path;
      }

      public void run(){

  try
    {
        Runtime rt = Runtime.getRuntime();
        Process proc = rt.exec(cmd , null, path);
        InputStream stderr = proc.getErrorStream();
        InputStreamReader isr = new InputStreamReader(stderr);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        System.out.println("<ERROR>");
        while ( (line = br.readLine()) != null)
            System.out.println(line);
        System.out.println("</ERROR>");
        int exitVal = proc.waitFor();
        System.out.println("Process exitValue: " + exitVal);
    } catch (Throwable t)
      {
        t.printStackTrace();
      }

and by referring to jtahlborn answer, I have done another Runnable class for GUI update purpose as well, as below:

       Runnable doWorkRunnable = new Runnable() {
        public void run() {
System.out.println("hello world");
btnTranscribe.setEnabled(false);
areaOutput.setEditable(false);
areaOutput.setEnabled(false);
areaOutput.setText("Performing segmentation, please wait till process is done\n"); }
        };

I call to SwingUtilities.invokeLater to change the GUI before actually running the process.exec() to call external program as showed below:

    SwingUtilities.invokeLater(doWorkRunnable);
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd , null, path);

but with all codes above, the GUI still failed to update and it is only updated after the process is done. Am I wrong at any particular steps in coordinating these two runnable and threads?

Thank in advance for your great help and answer

P / S: I start execute CmdExec() during a button is pressed in the GUI as below:

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 
     strSegment = "java -Xmx2024m -jar ./LIUM_SpkDiarization-4.2.jar / --fInputMask=" +               strAudioOut + "/%s.wav"
            + " --sOutputMask=" + strCtlOut + "/%s.ctl --sOutputFormat=ctl --            doCEClustering --cMinimumOfCluster=1 new3_20110331103858";

    CmdExec tryDemo = new CmdExec();
    tryDemo = new CmdExec(strSegment, fSegment);
    tryDemo.run();

    strExtract = "./sphinx_fe -i " + strAudioOut + "/new3_20110331103858.wav"
           + " -o " + strFeatureOut + "/new3_20110331103858.mfc";
    //System.out.println (strExtract);
    //executeCommand (strExtract, fExtract);

    tryDemo = new CmdExec(strExtract, fExtract);
    tryDemo.run();
      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:48:23+00:00Added an answer on May 20, 2026 at 10:48 pm

    you need to call tryDemo.start(), not tryDemo.run(). you are running the thread directly, not spawning a separate invocation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

referring to my previous question I came accross to another problem. The div I
Referring to a previous question , i was wondering if its always possible to
Ok, referring back to my previous question, I am still working on learning haskell
Referring to TLB and maintenance issues ... My question to people (often) using the
If I have two objects on the heap referring to each other but they
My co-worker posted a question on his blog . He is referring to rendering
int i,j; std::string s; std::cin>>i>>j>>s>>s>>i; std::cout<<i<< <<j<< <<s<< <<i; Question Referring to the sample
This question is a follow up to my previous Java GC question: Java Garbage
I've heard people referring to this table and was not sure what it was
I'm referring to distinctions such as in this answer : ...bash isn't for writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.