Solved

"Daemonizing" a Java program

Posted on 1998-08-17
3
244 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 79
Java - sorting a list of objects where the properties of the objects can change during the sort 7 47
eclipse argument 14 53
custom annotations 9 32
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now