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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:07:07+00:00 2026-05-15T11:07:07+00:00

My main field is .Net but recently I have got something to do with

  • 0

My main field is .Net but recently I have got something to do with Java. I have to create a shell utility in Java that could run in background reading few database records after specified duration and do further processing. It’s a kind of scheduler. Now I have few concerns:

How to make this work as a service. I want to execute it through a shell script and the utility should start running. Off course the control should get back to the calling script.

Secondly, eventually i may want to stop this process from running. How to achieve this?

I understand these are basic question but I really have no idea where to begin and what options are best for me.

Any help / advise please?

  • 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-15T11:07:08+00:00Added an answer on May 15, 2026 at 11:07 am

    I would go for the running the program using a scheduler or a service. However, if you wish to use a bat file and do this programmatically, I have outlined a possible approach below:

    In your Java program, you can get the PID programmatically, and then write it to a file:

    public static void writePID(String fileLocation) throws IOException
    {
        // Use the engine management bean in java to find out the pid
        // and to write to a file
        if (fileLocation.length() == 0)
        {
            fileLocation = DEFAULT_PID_FILE;
        }       
        String pid = ManagementFactory.getRuntimeMXBean().getName();
        if (pid.indexOf("@") != -1) 
        {
            pid = pid.substring(0, pid.indexOf("@"));
        }                                               
        BufferedWriter writer = new BufferedWriter(new FileWriter(fileLocation));
        writer.write(pid);
        writer.newLine();
        writer.flush();
        writer.close();                     
    }
    

    You can then write a stop .bat file that will kill the running program in windows. You could do something like:

    setlocal
    IF EXIST app.pid FOR /F %%i in ('type app.pid') do TASKKILL /F /PID %%i   
    IF EXIST app.pid DEL app.pid
    endlocal
    

    Of course, app.pid is the file written by the Java method above.

    I am not sure how you would be able to write a script that launches a java program, and reverts control on termination. I would be interested to see if anybody has a solution for that.

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

Sidebar

Related Questions

I got one main search field always visible at the site and a login
I have a program that uses three JTextField fields as the main data entry
Back Story: I was approached to write an app, but iOS isn't something that
I have a pretty big web application that I created last year using ASP.NET
I have a web app, that consumes a web service. The main page runs
If I want to parse a text field in SSJS there are 2 main
I have decided to use ASP.NET MVC to develop multi page (registration) forms in
This should be simple, but I am having problems. Using the eBay .Net library,
I'm refactoring a WinForms (.NET 4) application that makes use of a TabControl to
i have a regular html Grid and i am binding my asp.net mvc view

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.