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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:29:32+00:00 2026-06-18T22:29:32+00:00

Question What is the most efficient way of calling multiple commands from a Java

  • 0

Question
What is the most efficient way of calling multiple commands from a Java program?

Background
My team and I have been tasked with creating a program that eventually calls a series (anywhere from one hundred to ten thousand, or possibly more) of commands on a UNIX system. The commands are not simple, built-in commands, but rather are part of a software that has already been installed on the machine. Because these commands are fairly work-intensive and performance is a key factor in the success of our software, I have been researching the most efficient way of calling multiple commands from Java. Unfortunately, I have yet to find a single post, question, or forum that has discussed the calling of multiple commands from a performance perspective.

Knowledge
I am very familiar with IO in Java, and have worked with the Runtime, Process, and ProcessBuilder classes before.

What I’m Looking for
I am looking for a high or low-level (pseudo-only, if low-level, please) explanation of how to best optimize the calling of multiple commands from within a Java program. I am unable to post our code on the web, but I do not believe that our code is necessary, in this situation. For sake of ease, feel free to assume that the command we are calling is cmd, which takes arguments -a arg0 -b arg1. It may be helpful to know that the command strings are generated earlier in the program and do not change based on the results of other calls. It may also help to know that the results of all of the calls will be strings that are to be added to an ArrayList.

Thank you so much for your help.

  • 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-18T22:29:34+00:00Added an answer on June 18, 2026 at 10:29 pm

    I think the main issue here is parallel running of as many commands as can usefully be run in parallel. That will often make a far bigger difference in performance than any difference in exactly how the commands are managed.

    Generally, I agree with the idea of using a script of some sort, and having Java directly run only the script’s interpreter.

    In particular, in this sort of situation, I have sometimes used parallel make. The makefile can specify the commands to run, and any dependencies between them. For example, in a situation in which I needed to do hundreds of simulations, I had rules that made the raw simulation reports each depend on a simulation control file, and the processed reports depend on the raw reports.

    Parallel make can make it easy and efficient to resume work after a failure without redoing all the work that was successfully completed. It can also manage limiting parallelism to a reasonable number of threads.

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

Sidebar

Related Questions

I have a quick question re. the most efficient way to loop through multiple
In Java, what's the most efficient way to return the common elements from two
I have a question regarding the most efficient way to design a class that
I have a simple question about the most efficient way to perform a particular
Simple question: Which is the most efficient way of performing a substituion like: Some
Imagine you have a very long sequence. What is the most efficient way of
What is the most efficient way to select 2 unique random elements from an
i have a more or less general question about using coredata the most efficient
As a follow-up question to: Most efficient way to do a horizontal sliding layout
Continuing from Stack Overflow question Java program to get the current date without timestamp

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.