Results 1 to 4 of 4
  1. #1
    greengold is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default Java as Linux daemon

    Hi all!
    I would like to daemonize my java program as cassual linux daemons are.
    I have almost finished packet sniffer (IDS & IPS system) and I would like to use it as daemon in /etc/rc.d/myProg with {start|stop|restart|configure} options
    I imagime it in this way: program should be first configured ( /etc/rc.d/myProg configure ) so command prompt should ask for config settings that should be written to config file at the end and than daemon can be started.
    I have been googling it but I found just unclear articles about this topic or using & to run process in background or use of 'daemon' linux program.
    I want that right way to do this cause this is part of my bachelors exam (:
    Thanks for your help!

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    Most of those link lead to Apache deamon API.
    It is very small you can check src code, does this mean any good to you?

    Other path is to use Java Service Wrapper. Check it to and see how it meet your demands.

  3. #3
    greengold is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    I found java service wrapper ideal for me! thanks...
    I just need to set up the config file and I can't find out how :/
    can U halp me?
    Integration of wrapper service and basic wrapper.conf is here Java Service Wrapper - WrapperSimpleApp Integration (Linux / Unix)
    this is my structure of classic NetBeans project directory which contains program itself:
    Java Code:
    [root@timeline32 NetBeansProjects]# ls -saltR snifferBC/
    snifferBC/:
    total 52
    4 drwxrwxrwx 2 tepo users 4096 Nov  1 14:09 dist
    4 drwxrwxrwx 2 tepo users 4096 Nov  1 14:09 conf
    8 -rw-r--r-- 1 root root  6682 Nov  1 13:52 wrapper.log
    4 drwxrwxrwx 9 tepo users 4096 Nov  1 13:22 .
    4 drwxrwxrwx 2 tepo users 4096 Nov  1 13:13 logs
    4 drwxr-xr-x 7 tepo users 4096 Nov  1 12:59 ..
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 build
    4 -rwxrwxrwx 1 tepo users 3648 Oct 20 19:40 build.xml
    4 -rwxrwxrwx 1 tepo users   82 Oct 20 19:40 manifest.mf
    4 drwxrwxrwx 3 tepo users 4096 Oct 20 19:40 nbproject
    4 drwxrwxrwx 3 tepo users 4096 Oct 20 19:40 src
    4 drwxrwxrwx 2 tepo users 4096 Oct 20 19:40 test
    
    snifferBC/dist:
    total 568
      4 drwxrwxrwx 2 tepo users   4096 Nov  1 14:09 .
     20 -rwxrwxrwx 1 tepo users  18755 Nov  1 14:09 wrapper.log
      4 drwxrwxrwx 9 tepo users   4096 Nov  1 13:22 ..
     56 -rwxrwxrwx 1 tepo users  50010 Nov  1 13:02 snifferBC
     56 -rwxrwxrwx 1 tepo users  50003 Nov  1 13:02 snifferBC~
     56 -rwxrwxrwx 1 tepo users  50003 Nov  1 11:11 snifferBC.sh~
    112 -rwxrwxrwx 1 tepo users 106852 Oct 29 10:13 snifferBC.jar
    260 -rwxrwxrwx 1 tepo users 259727 Oct 16 07:47 wrapper
    
    snifferBC/conf:
    total 28
     4 drwxrwxrwx 2 tepo users 4096 Nov  1 14:09 .
     4 -rw-r--r-- 1 tepo users  420 Nov  1 14:09 wrapper.conf
     4 -rw-r--r-- 1 tepo users  384 Nov  1 14:09 wrapper.conf~
    12 -rwxrwxrwx 1 tepo users 8246 Nov  1 14:04 wrapper.conf.old
     4 drwxrwxrwx 9 tepo users 4096 Nov  1 13:22 ..
    
    snifferBC/logs:
    total 36
     4 drwxrwxrwx 9 tepo users  4096 Nov  1 13:22 ..
    28 -rwxrwxrwx 1 root root  25136 Nov  1 13:13 wrapper.log
     4 drwxrwxrwx 2 tepo users  4096 Nov  1 13:13 .
    
    snifferBC/build:
    total 20
    4 drwxrwxrwx 9 tepo users 4096 Nov  1 13:22 ..
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 classes
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 .
    4 -rwxrwxrwx 1 tepo users   73 Oct 29 10:13 built-jar.properties
    4 drwxrwxrwx 2 tepo users 4096 Oct 29 10:13 empty
    
    snifferBC/build/classes:
    total 16
    4 drwxrwxrwx 3 tepo users 4096 Nov  1 13:19 snifferbc
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 .
    4 drwxrwxrwx 3 tepo users 4096 Oct 29 10:13 jpcap
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 ..
    
    snifferBC/build/classes/snifferbc:
    total 104
     4 drwxrwxrwx 3 tepo users  4096 Nov  1 13:19 .
     4 drwxrwxrwx 4 tepo users  4096 Oct 29 10:13 ..
     4 drwxrwxrwx 3 tepo users  4096 Oct 29 10:13 jpcap
    20 -rwxrwxrwx 1 tepo users 17214 Oct 29 10:13 jpcap.jar
     4 -rwxrwxrwx 1 tepo users   969 Oct 29 10:13 JSniffer.class
    60 -rwxrwxrwx 1 tepo users 53262 Oct 29 10:13 libjpcap.so
     4 -rwxrwxrwx 1 tepo users  1579 Oct 29 10:13 looper.class
     4 -rwxrwxrwx 1 tepo users   487 Oct 29 10:13 Main.class
    
    snifferBC/build/classes/snifferbc/jpcap:
    total 16
    4 drwxrwxrwx 3 tepo users 4096 Nov  1 13:19 ..
    4 drwxrwxrwx 3 tepo users 4096 Oct 29 10:13 .
    4 -rwxrwxrwx 1 tepo users  347 Oct 29 10:13 package.html
    4 drwxrwxrwx 2 tepo users 4096 Oct 29 10:13 packet
    
    snifferBC/build/classes/snifferbc/jpcap/packet:
    total 12
    4 drwxrwxrwx 2 tepo users 4096 Oct 29 10:13 .
    4 drwxrwxrwx 3 tepo users 4096 Oct 29 10:13 ..
    4 -rwxrwxrwx 1 tepo users  206 Oct 29 10:13 package.html
    
    snifferBC/build/classes/jpcap:
    total 40
    4 drwxrwxrwx 3 tepo users 4096 Oct 29 10:13 .
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 ..
    4 -rwxrwxrwx 1 tepo users 2395 Oct 29 10:13 JpcapCaptor.class
    4 -rwxrwxrwx 1 tepo users  712 Oct 29 10:13 JpcapInstance.class
    4 -rwxrwxrwx 1 tepo users 1762 Oct 29 10:13 JpcapSender.class
    4 -rwxrwxrwx 1 tepo users 1000 Oct 29 10:13 JpcapWriter.class
    4 -rwxrwxrwx 1 tepo users  777 Oct 29 10:13 NetworkInterfaceAddress.class
    4 -rwxrwxrwx 1 tepo users  833 Oct 29 10:13 NetworkInterface.class
    4 drwxrwxrwx 2 tepo users 4096 Oct 29 10:13 packet
    4 -rwxrwxrwx 1 tepo users  166 Oct 29 10:13 PacketReceiver.class
    
    snifferBC/build/classes/jpcap/packet:
    total 48
    4 drwxrwxrwx 2 tepo users 4096 Oct 29 10:13 .
    4 drwxrwxrwx 3 tepo users 4096 Oct 29 10:13 ..
    4 -rwxrwxrwx 1 tepo users 3517 Oct 29 10:13 ARPPacket.class
    4 -rwxrwxrwx 1 tepo users  321 Oct 29 10:13 DatalinkPacket.class
    4 -rwxrwxrwx 1 tepo users 2060 Oct 29 10:13 EthernetPacket.class
    4 -rwxrwxrwx 1 tepo users 4095 Oct 29 10:13 ICMPPacket.class
    8 -rwxrwxrwx 1 tepo users 4784 Oct 29 10:13 IPPacket.class
    4 -rwxrwxrwx 1 tepo users 1937 Oct 29 10:13 IPv6Option.class
    4 -rwxrwxrwx 1 tepo users 1438 Oct 29 10:13 Packet.class
    4 -rwxrwxrwx 1 tepo users 2112 Oct 29 10:13 TCPPacket.class
    4 -rwxrwxrwx 1 tepo users  943 Oct 29 10:13 UDPPacket.class
    
    snifferBC/build/empty:
    total 8
    4 drwxrwxrwx 2 tepo users 4096 Oct 29 10:13 .
    4 drwxrwxrwx 4 tepo users 4096 Oct 29 10:13 ..
    
    snifferBC/nbproject:
    total 72
     4 drwxrwxrwx 9 tepo users  4096 Nov  1 13:22 ..
     4 -rwxrwxrwx 1 tepo users  2290 Oct 21 23:47 project.properties
     4 drwxrwxrwx 2 tepo users  4096 Oct 21 22:44 private
     4 drwxrwxrwx 3 tepo users  4096 Oct 20 19:40 .
    48 -rwxrwxrwx 1 tepo users 47888 Oct 20 19:40 build-impl.xml
     4 -rwxrwxrwx 1 tepo users   467 Oct 20 19:40 genfiles.properties
     4 -rwxrwxrwx 1 tepo users   502 Oct 20 19:40 project.xml
    
    snifferBC/nbproject/private:
    total 16
    4 -rwxrwxrwx 1 tepo users  207 Oct 26 20:02 private.xml
    4 -rwxrwxrwx 1 tepo users  150 Oct 21 22:44 private.properties
    4 drwxrwxrwx 2 tepo users 4096 Oct 21 22:44 .
    0 -rwxrwxrwx 1 tepo users    0 Oct 21 22:44 config.properties
    4 drwxrwxrwx 3 tepo users 4096 Oct 20 19:40 ..
    
    snifferBC/src:
    total 12
    4 drwxrwxrwx 9 tepo users 4096 Nov  1 13:22 ..
    4 drwxrwxrwx 3 tepo users 4096 Nov  1 13:05 snifferbc
    4 drwxrwxrwx 3 tepo users 4096 Oct 20 19:40 .
    
    snifferBC/src/snifferbc:
    total 264
      4 drwxrwxrwx 3 tepo users   4096 Nov  1 13:05 .
      4 -rwxrwxrwx 1 tepo users   1505 Oct 29 10:13 looper.java
      4 -rwxrwxrwx 1 tepo users    503 Oct 29 09:50 JSniffer.java
      4 -rwxrwxrwx 1 tepo users    418 Oct 28 20:53 Main.java
     20 -rwxrwxrwx 1 tepo users  17214 Oct 21 22:23 jpcap.jar
     60 -rwxrwxrwx 1 tepo users  53262 Oct 21 22:20 libjpcap.so
      4 drwxrwxrwx 3 tepo users   4096 Oct 20 19:40 ..
     40 -rwxrwxrwx 1 tepo users  38044 Oct 16 07:47 libwrapper.so
    120 -rwxrwxrwx 1 tepo users 114841 Oct 16 07:47 wrapper.jar
      4 drwxrwxrwx 3 tepo users   4096 Jan 10  2006 jpcap
    
    snifferBC/src/snifferbc/jpcap:
    total 48
    4 drwxrwxrwx 3 tepo users 4096 Nov  1 13:05 ..
    4 -rwxrwxrwx 1 tepo users 3030 Jun  9  2007 JpcapSender.java
    8 -rwxrwxrwx 1 tepo users 7746 Jun  9  2007 JpcapCaptor.java
    4 -rwxrwxrwx 1 tepo users 1094 Jun  9  2007 JpcapWriter.java
    4 drwxrwxrwx 3 tepo users 4096 Jan 10  2006 .
    4 -rwxrwxrwx 1 tepo users  500 Jan  2  2006 JpcapInstance.java
    4 -rwxrwxrwx 1 tepo users  556 Jan  1  2006 PacketReceiver.java
    4 drwxrwxrwx 2 tepo users 4096 Jan  1  2006 packet
    4 -rwxrwxrwx 1 tepo users  347 Jan  1  2006 package.html
    4 -rwxrwxrwx 1 tepo users 1073 Jan  1  2006 NetworkInterfaceAddress.java
    4 -rwxrwxrwx 1 tepo users 1226 Jan  1  2006 NetworkInterface.java
    
    snifferBC/src/snifferbc/jpcap/packet:
    total 60
    4 -rwxrwxrwx 1 tepo users 2627 Jun  9  2007 EthernetPacket.java
    8 -rwxrwxrwx 1 tepo users 7930 Jun  9  2007 IPPacket.java
    8 -rwxrwxrwx 1 tepo users 6491 Jun  9  2007 ICMPPacket.java
    4 -rwxrwxrwx 1 tepo users 2146 Jun  9  2007 IPv6Option.java
    4 -rwxrwxrwx 1 tepo users 1387 Jun  9  2007 Packet.java
    4 -rwxrwxrwx 1 tepo users  973 May 16  2007 UDPPacket.java
    4 -rwxrwxrwx 1 tepo users 3135 May 16  2007 TCPPacket.java
    8 -rwxrwxrwx 1 tepo users 5071 May 16  2007 ARPPacket.java
    4 -rwxrwxrwx 1 tepo users  154 May 16  2007 DatalinkPacket.java
    4 drwxrwxrwx 3 tepo users 4096 Jan 10  2006 ..
    4 -rwxrwxrwx 1 tepo users  206 Jan  1  2006 package.html
    4 drwxrwxrwx 2 tepo users 4096 Jan  1  2006 .
    
    snifferBC/test:
    total 8
    4 drwxrwxrwx 9 tepo users 4096 Nov  1 13:22 ..
    4 drwxrwxrwx 2 tepo users 4096 Oct 20 19:40 .
    I need to set up wrapper.java.classpath.#'s and wrapper.java.mainclass lines at wrapper.conf file.

    I would be very grateful for help (;
    Thanks!

  4. #4
    greengold is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Timer won't execute untill daemon thread yields
    By dsollen in forum Threads and Synchronization
    Replies: 1
    Last Post: 12-24-2009, 07:17 AM
  2. Replies: 6
    Last Post: 04-08-2009, 04:05 AM
  3. Java On Linux
    By Natrix in forum New To Java
    Replies: 15
    Last Post: 04-08-2009, 12:31 AM
  4. [SOLVED] should I run my Timer as a daemon?
    By Goseph in forum Threads and Synchronization
    Replies: 7
    Last Post: 02-16-2009, 10:22 AM
  5. Multithreaded daemon? High level help needed.
    By y0y in forum New To Java
    Replies: 4
    Last Post: 02-05-2009, 06:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •