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

  • SEARCH
  • Home
  • 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 8986345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:31:40+00:00 2026-06-15T21:31:40+00:00

Im missing something, I’ve created a calss based on callable and in my gui

  • 0

Im missing something, I’ve created a calss based on callable and in my gui creating an instance and calling it when a action is performed. the only thing is that the GUI is unresponsive as the process is running on the same thread and has to wait for it to finish before I can access the GUI. Here is some of the Code:

public class MYProject {
public static class CreateProject implements Callable<Boolean>{
    private String m_url;
    private String m_project;
    private String m_options;
    public CreateProject(String url, String project, String options){
        m_url = url;
        m_project = project;
        m_options = options;
    }
    public Boolean call(){
        Boolean result = true;
        try {
            if (os.toLowerCase().contains("windows")){
                command = windowsCMD + command;
            }
            String line;
            Process p = Runtime.getRuntime().exec(command);
            InputStreamReader isr = new InputStreamReader(p.getInputStream());
            BufferedReader bri = new BufferedReader(isr);
            try {
                while ((line = bri.readLine()) != null) {
                    if(line.startsWith("ERROR")){
                        System.out.println(line);
                        result = false;
                        break;
                    }
                }
                p.waitFor();
            }
            finally {
                bri.close();
            }
        }
        catch (Exception err) {
            System.err.println("Unable to create project: " + err.getMessage() 
                                + "\n");
            result = false;
        }
        return result;
    }
}
}

and in the GUI:

private void jButtonRefreshActionPerformed(java.awt.event.ActionEvent evt) {
    jTextAreaConsole.append("Creating project.\n");
    MYProject.CreateProject blah = new MYProject.CreateProject("url", "project", "options");
    String result = blah.call();
    jTextAreaConsole.append("Project creation successful: " + result);
}

The result being Process p is still running on the same thread as the gui and nothing is clickable and the jTextAreaConsole doesnt update until after the process has finished. Can any one offer some advice on how I should be implementing this?

  • 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-06-15T21:31:41+00:00Added an answer on June 15, 2026 at 9:31 pm

    The result being Process p is still running on the same thread as the
    gui and nothing is clickable and the jTextAreaConsole

    Yes it is doing exactly what p.waitFor(); in your code

    waitFor()
    

    Causes the current thread to wait, if necessary, until the process represented by this Process object has terminated.

    from

    Process Class

    You might want to use SwingWorker like @Andrew Thompson posted
    Or you can implement Runnable´s run method and start it in a new thread
    Or even using the Executor class like @hoaz posted

    For the callable to run in a separete thread you need to use Executors

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

Sidebar

Related Questions

Hopefully I'm not missing something obvious... I'm creating a function that will ease in
I'm obviously missing something simply, and know the problem is that it's creating a
Probably missing something completely obvious here, but here goes. I'm starting out with Spring
Must be missing something really obvious here but how do you change the size
I may be missing something about the fundamentals of WPF design, but I was
I may be missing something, but I'm sure that I've checked everything, I forked
I am missing something in my SQL query, could please someone advise how to
I am abviously missing something, but I keep getting this message when trying to
Maybe im missing something but im not sure. All im simply trying to do
I think I'm missing something really obvious here... must be... but for some reason

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.