Solved

"Daemonizing" a Java program

Posted on 1998-08-17
3
247 Views
Last Modified: 2012-06-22
Is it possible to detach a Java program from its terminal, eg the MSDOS prompt for Win95, or the xterm for Lynix??? I have been banging my head against the wall for quite a while on this. Some process similar to giving a thread daemon status on Unix-based machines. Instantiating a new class inside a thread with setDaemon(true) and then exiting does not work! Any other ideas/options.

Thx,
  jdyer
0
Comment
Question by:jdyer
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
evijay earned 70 total points
ID: 1222008
Use javaw instead of java to run the program.

say you have a test daemon Test.class

run it using


javaw Test

If you want a daemon to start when the user logs in

in nt, you put command javaw classname in the startup panel.
in unix, add this in initialization file.


0
 
LVL 4

Expert Comment

by:evijay
ID: 1222009
you can close the input and output streams,

System.in.close();

System.out.close();
System.err.close();

This detaches java program from terminal.


0
 
LVL 1

Author Comment

by:jdyer
ID: 1222010
Thx so much, I had never noticed that or used that program in 1-1/2 years of Java programming. Time to look over the docs again I guess.

Thanx for waking me up!
 - jdyer

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question