This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Executing a sh file from java program in foreground Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Executing a sh file from java program in foreground" Watch "Executing a sh file from java program in foreground" New topic
Author

Executing a sh file from java program in foreground

Mukti chandnani
Greenhorn

Joined: Jul 01, 2008
Posts: 6
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

Joined: Sep 26, 2006
Posts: 9345
    
    2

What do you mean here by foreground and background? Can you please be a bit more elaborate?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2231
    
    7

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing a sh file from java program in foreground
 
Similar Threads
Issue with weblogic 10 on struts form bean
Need suggestions for improving the performance of the Tomcat server in production environment
JVM process memory VS object heap memory
Weblogic's performance tunning
Memory Args:What does -Xmn stand for ?