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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:38:55+00:00 2026-06-10T11:38:55+00:00

I have to make a java program that when user enters 0 it should

  • 0

I have to make a java program that when user enters 0 it should exit. no problem writing in java code.

int cmd = read();
System.out.println("got command : " + cmd);
if (cmd == 48) { // ASCII code for 0
System.exit(0);

I want to run this process using start-stop script in linux. I am also being able to do that using & or nohup

case "$1" in    
  'start')
    if [ -f myfifo ]; then
      rm myfifo
    fi
    mkfifo myfifo
    cat > myfifo &
    echo $! > myfifo-cat-pid
    java -jar myjar.jar >/dev/null 2>&1 0<myfifo &
    echo "Started process: "$!
    ;;

  'stop')
    echo 0 > myfifo
    echo "Stopped process: "
    rm myfifo
    ;;
esac

My problem is as soon as i run this process it read input -1. While I want to read from stdinput when somthing is echoed to it explicitly i.e. stop is called. Simply i need a program to be closed by shell script explicitly. I have tried hard. Help me.

Edit :

I just want to close the program when user press q or any such event and dont want infinite loop in code. Any other approach like listening to other events will also help if possible. My code should not be polling for event. I have tried Jnotify which watch a directory and rise an event when file is created or deleted in that directory. But hard luck they dont have support for SunOS. 🙁

  • 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-10T11:38:56+00:00Added an answer on June 10, 2026 at 11:38 am

    If you use set -m at the top of your shell script (hence enabling forcefully job control), you should see a consistent behavior.

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

Sidebar

Related Questions

I have to code a Java program that will receive messages from network and
I have a simple Java program that allows a user to draw rectangles on
I have a java program that processes information, but I want to make it
I am new in java. I try to make a program and I have
I have a project in Java and I need to make a code listing
I'm trying to make a bash script that will talk to a java program
I'm new at Java GUI and I'm trying to make a program that shows
I have a Java program that loads thirdparty class files (classes I did not
This is my problem. I have a program that has to run in a
I have a program that lets a user select any .class or .jar file

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.