Regarding System Proces

I am working on a java based project. I have one problem, My application is based on OSGI frame work.

So when user start the application i have to do the following....

Look for port 80 if any server/services is there i have to kill that service. And Start my small http server on it.

So i am not able to get the handle for the process in java to kill the service through my application. I have to make this work on windows and linux.

Can any one tell me how to start with this.

thanks

[521 byte] By [javajain] at [2007-9-27 19:16:35]
# 1

The crucial point is how to know which process listens on a given port. If you know that (and have the appropriate privileges) you can "kill" the process in the appropriate platform-specific way.

On Unix/Linux you know what ports are listened on:

$ netstat -na|grep -i listen|grep tcp

tcp00 0.0.0.0:513 0.0.0.0:*LISTEN

tcp00 0.0.0.0:37 0.0.0.0:*LISTEN

tcp00 0.0.0.0:79 0.0.0.0:*LISTEN

tcp00 0.0.0.0:60000.0.0.0:*LISTEN

tcp00 0.0.0.0:12340.0.0.0:*LISTEN

tcp00 0.0.0.0:21 0.0.0.0:*LISTEN

tcp00 0.0.0.0:23 0.0.0.0:*LISTEN

tcp00 :::22:::*LISTEN

Wow! 1234 looks cool! Who is there?

$ fuser -n tcp 1234

1234/tcp: 3088

And what is porcess 3088?

$ ps -p 3088 -f

UIDPID PPID C STIME TTY TIME CMD

ijbalazs 30881 0 Sep16 pts/200:00:05 /usr/lib/jdk1.2.2/bin/i386/green_threads/java -classpath /home/ijbalazs/source/java/ZipServer ZipServer 1234

Okay, now I remember: it is a java program, a "ZipServer": a little web server (written in Java) which serves requests from zip-archives. Thus I (and potentially others on this side on the firewall) can browse for example the various java documentations without having to unzip them.

BIJ at 2007-7-6 21:50:17 > top of Java-index,Core,Core APIs...