Friday, March 4, 2011

Compiling Openfire XMPP chat server with IKVM Java to .NET runtime

Openfire is a rather nice and usable XMPP chat server. It does have one caveat: a dependance on Java; which, given your views of the Oracle takeover, is either good or bad. Another annoyance: on a Windows box, if you want IPv6 clients to connect, you can't run stone and redirect the necessary TCP ports (5222,5223,9090,9091) while Oracle Java is running (Java7 supports IPv6 on post-XP systems, but its currently still "non-production").

Solution: IKVM. It can recompile Java apps as .NET programs, using code that was open-sourced by Sun. There may also be some native support for IPv6 (IKVM has some IPv6 support, but doesn't seem to work well enough yet).


*. The latest usable IKVM bin: usually announced on their weblog
*. An available Java Runtime: you'll need it to unpack some of the JAR files.
*. The latest ZIP file for OpenFire.
*. IPv6 client access may need stone installed as a service; I already have a package for that (add the extra ports to the correct stone.ini).

Install process

1. Extract IKVM to something like c:\ikvm
2. Extract OpenFire to something like c:\openfire
3. Install a working JRE as able.
4. Install the stone proxy service if you need it for IPv6 clients.
5. Copy the following batch file, and edit the SET paths to where to installed/saved steps 1-3.
6. To automatically run your chat server in the background, use Task Manager to create a new task (Vista/2008 or newer) for the openfire.exe the batchfile creates.
7. You can optionally uninstall the JRE.

Batch file to compile the software...

REM Build OpenFire with IKVM

SET jrebindir=C:\PROGRA~1\Java\jre6\bin
SET ikvmbindir=C:\IKVM\bin
SET openfiredir=C:\openfire
cd %openfiredir%\lib

REM Decompress
%jrebindir%\unpack200 -r commons-el.jar.pack commons-el.jar
%jrebindir%\unpack200 -r hsqldb.jar.pack hsqldb.jar
%jrebindir%\unpack200 -r jasper-compiler.jar.pack jasper-compiler.jar
%jrebindir%\unpack200 -r jasper-runtime.jar.pack jasper-runtime.jar
%jrebindir%\unpack200 -r jtds.jar.pack jtds.jar
%jrebindir%\unpack200 -r mysql.jar.pack mysql.jar
%jrebindir%\unpack200 -r openfire.jar.pack openfire.jar
%jrebindir%\unpack200 -r postgres.jar.pack postgres.jar
%jrebindir%\unpack200 -r servlet.jar.pack servlet.jar
%jrebindir%\unpack200 -r slf4j-log4j12.jar.pack slf4j-log4j12.jar

REM Compile main
%ikvmbindir%\ikvmc -lib:%openfiredir%\lib -recurse:%openfiredir%\lib -target:exe -out:openfire.exe -main:org.jivesoftware.openfire.starter.ServerStarter startup.jar

REM Move results to BIN
move *.exe ../bin
move *.dll ../bin
move *.xml ../bin

copy %ikvmbindir%\*.dll %openfiredir%\bin


  1. Nice. A not about "byebye v4" widget on the right of your blog. When I click "Hurican Electric" logo at the bottom, it loads page, but in the the same small iframe. Please change target to _blank if you can.

  2. I went ahead and pulled the widget, since v4 exhaustion happened, and I can't edit the widget directly. If you want to check out HE's website, go to