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

The Archive Base Latest Questions

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

I have a Java console application that is launched from a batch script in

  • 0

I have a Java console application that is launched from a batch script in Windows and a shell script in Linux. In both cases, any command-line arguments (which are complex) are simply passed into the java app, which interprets them using Apache Commons CLI.

Now I want to allow users to allocate additional memory to the program. The simplest approach might be to have an additional argument for this (e.g. -m 1000), but there are drawbacks. Both the batch and shell scripts would now need to interpret the command line so they can pluck out the memory argument and use it as an -Xmx parameter for the JVM. This effectively means catering for the full complexity of argument parsing in 3 places (batch/shell/java).

The only other approach that springs to mind is to have the scripts call a dummy Java application, which uses the existing parsing logic to find the new argument, then fork another JVM to run the main application, using the correct memory ceiling (using Runtime.exec()). This would get around the code duplication issue.

My question is – does this seem like a bad idea to anyone? Perhaps there are issues I’m not considering.

  • 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-16T22:32:23+00:00Added an answer on May 16, 2026 at 10:32 pm

    Unless you need very high performance, I think it’s OK. At work, we use the same approach for a similar problem: the user double clicks on the applications jar file; this jar file then starts another process with the right amount of memory (-Xmx512m usually).

    Things to consider: can the user add additional jar files to the classpath? Can the user set a different JVM to use? If yes it might be tricky. You should also ensure the process ends. You may need to redirect the input stream, output stream and error stream, probably using separate threads.

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

Sidebar

Related Questions

I have one application that prints messages from Test.exe in console .My java program
i have my application that sometimes will freeze, without any error in console. I
I have a Java Web Start Application that I launch from live site by
i have a console application that generated from bison (a parser) and i want
I've created a NetBeans Platform application that is launched using Java Web Start. I
I have created a java SE application that uses the mysql database using mysql
I have a multi-threaded Java application that will output information about a message it
I have a thread in a Java web application that causes a java.lang.OutOfMemoryError: Java
I used this line to execute a python script from a java application: Process
I have a simple console application that runs calculations in several threads (10-20 of

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.