Finding the process id of the process owning a port

Occasionally there’s time where you need to find out what process owns a port currently open.

On the Mac this can be done easily by using the following line – here we are looking for port 8080:

ps u –no-heading -p  `netstat -nlept | awk ‘/[:]8080 / {split ($9,t,”/”); print t[1]}’` 2>/dev/null

For windows you don’t have a decent shell (and cygwin would probably not work here), so you can use the following batch script to do the same:

@echo off

for /F “usebackq tokens=5″ %%f in (`netstat -b -n ^| find “:%1″`) do call :process %%f

goto :eof


tasklist /FI “PID eq %1″ /NH

If the above code was called findport.bat then running findport 8080 would then find the process owning port 8080.

Using the retepMicroKernel – Part 1

In the first of four posts introducing the retepMicroKernel project, I will describe what the project is, it’s goals and how it can be used to implement lightweight server side application running either standalone or within a J2EE environment. Part 2 will show how to write an application for the kernel and Part 3 will show how to add a web console to your application while Part 4 will show how to integrate an application into a J2EE environment.


The retepMicroKernel comprises four distinct components:

  • Binary launcher
  • MicroKernel
  • WebConsole
  • Apache Maven plugin


Binary launcher

The binary launcher is a platform specific binary who’s job is to configure the application, start the Java virtual machine and finally start the application by bootstrapping the microKernel.

Currently the following platforms are supported:

  • Linux (both 32 and 64 bit ). This is compiled under Ubuntu but is tested on RHEL4 so should work on most x86 and amd64 distributions
  • Mac OSx (Leopard 10.5.x and Java 6 required)
  • Windows XP (not tested on Vista, currently console only)

Other platforms will be supported as an when I get a working virtual image of those platforms.


This is the core kernel comprising the microKernel, annotations and core services like the in-memory JNDI server.


The WebConsole is an optional component that, when installed, provides a simple but comprehensive console for your application by utilising the built in web server provided by Java 6. With it you can monitor various statistics about your application using any web browser, and add additional actions to your application for management purposes.

Apache Maven plugin

The Apache Maven plugin enables an application to be built, ensuring that all artifacts are present and installed in the correct locations required by the kernel.

Directory Layout

Each microKernel application is organised so that the final application is self contained. Here’s the directory structure – here the application is called myapp:

  • bin – The binary launchers
  • etc – The application’s configuration
  • lib – The microKernel’s jar files
  • lib/myapp – The jar files for the myapp application

The contents of these directories will be covered in Part 2, but the layout is such that you can have multiple applications deployed in the same directory structure – simply have a copy of the binaries with the correct name, configuration under etc and a directory under lib with the application specific jars. In addition, the maven plugin handles all of this for you as it will generate the entire directory structure, ensure the correct artifacts are installed and generate a zip, tar.gz or tar.bz2 artifact containing the final application.

That’s all for the introduction, next in Part 2 I’ll go into depth on how to write a simple application with beans defined either in the standard spring xml fashon, or by utilising the supplied annotations.

Well yet again I’ve succumbed

It’s happened again – I’ve succumbed to another popular technology, this time blogging. It had to happen at some point, but after some resistence, here it is.

Over time, I’ll be adding entries on how to do various things with Java programming, specifically in the areas of J2EE, Astronomy and DataBases, although I do dabble in some other areas like A.I. Chatbots e.t.c.

%d bloggers like this: