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 7159737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:16:50+00:00 2026-05-28T13:16:50+00:00

I have sample java code like below. String testEfdDirectoryPath=D:\\test; String efdExecutable = test.cmd; File

  • 0

I have sample java code like below.

    String testEfdDirectoryPath="D:\\test";
    String efdExecutable = "test.cmd";
    File executableFile = new File(testEfdDirectoryPath, efdExecutable);
    ProcessBuilder pb=new ProcessBuilder();
    $$pb.command("cmd.exe","/C",executableFile.toString());$$
    pb.directory(new File(testEfdDirectoryPath));
    Process p=pb.start();
    int code=p.waitFor();
    System.out.print(code);

In test.cmd there is actually a call to another java application. Unless I change the $$ marked line to the following to redirect its output, the another java app cannot be launched.

    pb.command("cmd.exe","/C",executableFile.toString(),">output.txt");

Do you guys have any ideas? Thanks in advance. 🙂

  • 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-28T13:16:51+00:00Added an answer on May 28, 2026 at 1:16 pm

    Does your child process produce a lot of output (more than a few kilobytes)? If that is the case, you need to read that output from the process. You should try:

    1. start the process
    2. close the stdin of the process, so pb.getOutputStream().close()
    3. repeatedly read from pb.getInputStream() and the error stream

    This may be possible in one thread, or in multiple threads. Anyway, you should just take the explanation above as a list of keywords and try to search for an example code snippet that you can trust, preferrably from an Open Source application that does such a thing successfully.

    Maybe http://commons.apache.org/exec/ can help you.

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

Sidebar

Related Questions

I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
I have created a sample java socket application. I used Socket s = new
I have an output in the console from my code like the sample given
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have a very simple Java RMI Server that looks like the following: import
I have a custom java log4j appender class like com.xyz.abc.MyCustomAppender. I am able to
I would like to call an R script from Java. I have done google
I am in a very peculiar state. I have a list something like below
I have a list of words in a file. They might contain words like
In trying to write more testable Java code, I have been using the Model-View-Presenter

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.