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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:59:43+00:00 2026-06-04T16:59:43+00:00

i want to run a bash script with java ee / servlets . I

  • 0

i want to run a bash script with java ee / servlets .
I want it embedded in a web application , using tomcat 7 in a linux os.

  • 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-04T16:59:45+00:00Added an answer on June 4, 2026 at 4:59 pm
    1. Embed the script in the web application, at the root of the war file for example.
    2. Get the path to the file once the application is deployed with:

      String scriptPath = getServletContext().getRealPath("/script.sh");

    3. Run the script with the ProcessBuilder class:

      new ProcessBuilder("/bin/sh", scriptPath).start();

    Note that the step 2 may fail if you servlet container doesn’t extract the content of the war file. In this case you’ll have to put the script as a resource available on the classpath, copy its content into a temporary file, and run the script there.

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

Sidebar

Related Questions

I have a java application and I want to run a script whenever it
I have a web application writen in jsp/servlets & tomcat 7.It will run on
I want run a script as follows: runner: ssh 'java program &' ssh 'java
I want to run several REST web applications inside one Java process to save
I want to write a bash script where I run two commands simultaneously, then
I’ve a bash script I’ve been using for a Linux environment but now I
I have a bash script I want to run every 5 minutes from cron...
I want run a Bash script as root , but delayed. How can I
I want to run a program from inside a bash script, such that it
I'm trying to run a bash script from inside java that will live on

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.