Java, Tutorials

Agent Mobility with JADE and JIPMS

A friend and I have been working on Java Agent DEvelopment Framework (JADE) for a while now. The idea is to enhance security mechanisms in the open source agent-deployment platform. The first step we decided to address was the actual mobility of an agent from one platform (in the sense of a dedicated machine running the JADE middleware) to another one. Turned out that it was much harder than one would imagine — especially given the fact that these agents are supposed to be mobile. Anyway, after around two months of part-time efforts, we got the agent working. Since the whole ordeal involved a lot of missing documentation and bad support, I decided to document the process through this tutorial. So, here it is. Read on to see how you can create an agent on one platform, migrate it to another platform, have it do some computation there and come back to the source. 

Continue reading “Agent Mobility with JADE and JIPMS”

Android, Geek stuff, Java, research

A much better (and useful) eclipse plugin

It’s been four days since I started working with eclipse plugins and I finally have my first useful plugin. It’s useful for my research purposes and hopefully for a small audience interested in my work. It might also be useful for those trying to learn how to write eclipse plugins because I’ll soon be writing a tutorial on how I put this thing together from scratch (inshallah).

For the time being though, enjoy the screenshot.

Update: fixed the plugin with a new ‘View’. It now operates much better with a separate view for the output and controls. Also added is a ‘Hierarchy’ view for viewing the policy in a nice tree structure.

Java, Tutorials

Writing a Minimal Eclipse Plugin

I have tried, on multiple occasions, to write an eclipse plugin. I always gave up in the middle of the process though, what with the different versions of eclipse floating around and the discrepancies between the tutorials and the version I was using. I finally decided to sit down and go through a simple ‘hello world’ plugin and write a tutorial in the process to guide those that are using the latest eclipse. This is a tutorial for eclipse 3.5 (galileo) and is a no BS tutorial with little or no explanation. That’s because I believe in code first, think later approach when learning new technologies. So, download eclipse SDK version (not the Java or the C/C++ version) and read on.

Continue reading “Writing a Minimal Eclipse Plugin”

Announcements, Java, research

Joined JCP for Participation in JSR321

I have joined the Java Community Process (JCP) which is a platform for creation, review and approval of java specifcations in the form of Java Specification Requests (JSRs). My motivation is to participate in JSR321 “Trusted Computing”. The official description is as follows:

“The Trusted Computing Group developed a standard API for accessing Trusted Computing functionality from applications, the Trusted Software Stack (TSS). The TSS is targeted at applications written in the C-language. To make use of TC-functionality from Java, two groups have developed prototype solutions:

  • MIT CSAIL has developed TMP/J, an object-oriented API using Java for low-level access to the TPM.
  • IAIK, Graz University of Technology has developed the jTSS-Wrapper, a Wrapper making standard TSS implementations accessible from Java, and also jTSS, a native implementation of the TCG Software Stack.

The TSS-based activities followed the C-Specifications of the TCG, the resulting API obviously is not ideal for the Java world. The proposed JSR is to develop a Trusted Software Stack for Java providing comparable functionality the TSS offers to the C world.”

In simple words, the JSR aims to create a new Java namespace called javax.trustedComputing for the Java SE/EE platforms. See more about the JSR at:

I have been added to the JSR Expert Group on and await the completion of my agreement with Sun for formal induction in the JSR at JCP.

Java, Tutorials

XPath Example

A simple XPath example using JAXP only:

package serg.xslt;import*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.*;
import org.w3c.dom.traversal.NodeIterator;
import org.xml.sax.InputSource;

public class PathSelector {
public static void main(String arg[]) throws Exception {

 	String filename = null;
 	String xpath = null;
 	filename = arg[0];
 	// xpath = arg[1];
	xpath = "//book/following-sibling::*";
	// set up a dom tree

 	InputSource in = new InputSource(new FileInputStream(filename));
 	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 	Document doc = dbf.newDocumentBuilder().parse(in); 
	System.out.println("Querying Dom using : " + xpath);
 	CachedXPathAPI path = new CachedXPathAPI();
 	NodeIterator nl = path.selectNodeIterator(doc, xpath); 
 	// the actual XPath selector
	Transformer trans = TransformerFactory.newInstance().newTransformer();
 	trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");


 	Node n;

 	while ((n = nl.nextNode()) != null) {
 		trans.transform(new DOMSource(n), new StreamResult(
 				new OutputStreamWriter(System.out)));

Java, Tutorials

Web Services Example 1

After creating a successful environment for web services in Eclipse, it’s time to take things to another level by writing a service that actually does something. Here, we create a web service (still a simple one) which takes the salaries of employees, including allowances, and calculates their taxes. The client sends an XML document and receives the same document back except the taxes are now filled in. Later in our SOA course, we’ll see how these documents can be encrypted and signed to ensure integrity and privacy. Anyway, let’s get on with the web service.

Continue reading “Web Services Example 1”

C++, Java, Lisp, resources, Softwares

Eclipse, Java, C++, Lisp, LaTeX and Isabelle

I’ve recently re-discovered Eclipse. My first encounter with it was back when I was learning Prolog. I worked with it and while I liked the work-flow, I never got to using it full-time. It’s back and it’s staying.

Most people may think of Eclipse as simply a Java IDE but there’s a lot more to it that just that. Eclipse is at heart, a plugin framework and is very very extensible. Let me tell you why:

I’ve configured Eclipse to work as my primary C++ IDE, as my primary Lisp IDE, as my thesis word processor using LaTeX and am working on using it for as my Java IDE too. Now, I may be wrong but there’s no other IDE which can do all this.

As an example, see how easy it is to get Lisp working in Eclipse on Linux.

  • Download CUSP plugin for Eclipse
  • Extract the contents of the archive
  • Copy the folder jasko.tim.lisp to the plugins folder of Eclipse
  • The Lisp distro used is SBCL which sits in the sbcl sub-folder
  • Create a symbolic link to sbcl executable in someplace accessible globallly:

ln -s /usr/share/eclipse/plugins/jasko.tim.lisp/sbcl/sbcl /usr/bin/sbcl

  • assuming you installed Eclipse in /usr/share
  • Start Eclipse and change perspective to Lisp.

Six easy steps and you have a lovely Lisp IDE. Oh, and if you’re worried about Java being a “slow” language, you haven’t been around the latest JREs. Get the latest JRE and try Eclipse. You’ll love it.

Now, if I can only get my Isabelle to work with Eclipse! Yes, there is a plugin that does this. It’s just too crude right now.