0

I have to build Java daemon process that once starts will always be working (and listening to an open socket) in Linux, Windows and Mac.

I saw a few solutions on the web, but didn't find anything consistent and widely used. What are developers using for such task?

3

2 Answers 2

2

Simplest way to do it is to create batch file(win)/shell script(linux) and invoke that in inittab (linux) or windows startup. That's makes life easier. In that batch/shell file, simply call java binary with parameters

java background/daemon/service cross platform best practices

Sign up to request clarification or add additional context in comments.

2 Comments

You usually need to consider some more details in order to run a Java application as a real background process / daemon. Windows startup folder is not very well suited to run processes as a daemon.
Agreed that windows startup folder may not be the best one but startup could be placed in registry or task as well. Also running as daemon is "start <java / javaw> <parameters>" (zeroflag.wordpress.com/2007/05/12/start-command). If you really need bigger solutions, there are a few around (can't remember names though).
0

Use javaw from an system execute command in a c program in windows to make the "nicest" deamon in windows. Then have the c program loaded into the registry under startup, or place it in the startup folder, but that is easely edited by your customers which may not be desireable.

Otherwise the command prompt window will keep bugging you/your client.

For linux & mac etc... it's easy, simply load the java command into init.d

Don't know if I'd prefer java as a deamon though.... It's a bit bulky compared to a c deamon.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.