I am not a Java person and jPOS is an amazing iso8683 framework which I always wanted to try but it is written in Java. After some internet searching i figured out that it would be possible to use jPOS via C#. Below are some simple steps to get you started.

1. http://www.ikvm.net/ – This is an implementation of Java for .NET

2. http://www.jpos.org/ – The jPOS framework

In order to access jPOS via C# what you need to do is to use iKVM to create a DLL file of the equivalent JAR file that jPOS produces once is compiled. Below are the steps i followed:

1. Download and compile jPOS from above link (you should end up with the jpos.jar and some other jars)

I compiled jPOS on Ubuntu instance where is easy to isntall maven and any other tools needed. After compilation (screenshots above of the shared linux directory where i compiled jpos) you have the below .jar files:

  1. bsh-2.0b5.jar
  2. commons-cli-1.2.jar
  3. javatuples-1.2.jar
  4. jdbm-1.0.jar
  5. jdom-1.1.3.jar
  6. je-4.1.10.jar
  7. jline-1.0.jar
  8. jpos-1.8.5-SNAPSHOT.jar

2. Download and install iKVM and OpenJDK from above link. (ikvmbin-7.0.4335.0.zip and openjdk7-b147-stripped.zip)

I installed mine at the below location. Once i installed i moved all *.jar files from above to my bin directory of my iKVM installation where the utility “ikvmc.exe” is located:

4. Run ikvmc on jpos.jar to create jpos.dll (you should end up with the jpos.dll)

The above command “ikvmc.exe -target:library *.jar -out:jpos.dll” will combine all jar files into one single dll. This dll will be referenced in a Visual Studio C# Project so we can use jPOS library components in our Windows Forms C# Application

5. Create Visual Studio Project and add reference to jpos.dll

Create a simple Windows Forms C# project. Click on References and add reference to jpos.dll like below:

This reference is not enough you will also need to add “IKVM.OpenJDK.Core.dll” reference otherwise your code will not compile (if you reference jPOS components)

Adjust your code to look like below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

/*
* jPOS related
*/

using org.jpos.iso;
using org.jpos.util;
using org.jpos.iso.channel;
using org.jpos.iso.packager;

namespace TestingJPOS
{
public partial class Form1 : Form
{
/*
* jPOS related
*/

ISOChannel channel = new ASCIIChannel(“localhost”, 9999, new ISO87APackager());

Logger logger = new Logger();

public Form1()
{
InitializeComponent();

/*
* After Initialization do some jpos stuff
*/

/*
* jPOS related
*/

logger.addListener(new SimpleLogListener());

((LogSource)channel).setLogger(logger, “test-channel”);

}

private void button1_Click(object sender, EventArgs e)
{

/*
* jPOS related
*/
if (!channel.isConnected())
channel.connect ();

ISOMsg m = new ISOMsg ();

m.setMTI (“0800”);
m.set (3, “000000”);
m.set (41, “00000001”);
m.set (70, “301”);

channel.send (m);

//ISOMsg r = channel.receive ();

//channel.disconnect ();
}
}
}

Compile and run. You need to start some Listener to listen on port 9999 that this porgram will connect to, otherwise you will get some exception.

You will see in Visual Studio window if you run the above for debugging the below, which is the jPOS logger outputting tracing on standard output:

6. Create a simple application to demonstrate how it can be used