File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Starting a java process via servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Starting a java process via servlet" Watch "Starting a java process via servlet" New topic
Author

Starting a java process via servlet

Rajpreet Bajwa
Greenhorn

Joined: Feb 09, 2002
Posts: 14
I have written a simple server which listens to a queue and when it gets a message processes it. Now I want this server to run all the time and have the following options - I am using Tomcat.

1. Write a script which runs the main method and periodically checks if the process is running , if not then start the process.

2. (I am leaning towards this one) Write a servlet that initializes on start up and starts the server. This would be nice since I can let the container manage the starting/stopping etc, also there is a web console for people to monitor the server and I can add more things for monitoring. Is there any reason this is not a good idea ? What are the limitations of running my process within the container ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

I think running the application as a service is a better idea. For Windows you need to search for "Java Service Wrapper", a solution that can wrap your Java programs into a Windows service.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Originally posted by Rob Prime:
I think running the application as a service is a better idea. For Windows you need to search for "Java Service Wrapper", a solution that can wrap your Java programs into a Windows service.


The "Java Service Wrapper" is not just for windows - it is for almost all platforms
[ September 30, 2008: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Even better!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Starting a java process via servlet