Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing a sh file from java program in foreground

 
Mukti chandnani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

My purpose is to restart my Java application from within the application.
For this I have created a Java program that runs a sh file. This sh file has the command to start the same java Program.
when i run the parent Java program it executes the sh file and runs the Java Program in it in background. I want this program to run in foreground since the program takes inputs from the user. How can i make the program run in foreground.

Following is the code i use to execute the sh file



Following is sh file



Thanks
 
Joe Harry
Ranch Hand
Posts: 10077
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean here by foreground and background? Can you please be a bit more elaborate?
 
K. Tsang
Bartender
Posts: 3347
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly you should able to use the command "fg" to bring your background job to the foreground. However, I don't know how to put this running foreground job back to background because you are inside the java program. If you Ctrl+C you then exit the java program killing the job. At least that's what I got on my linux box.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic