jNetPcap v2 - Implementation

No replies
Mark Bednarczyk
Offline
Joined: 03/22/2008
public class HelloWorld {

	public native static String createString()
	/*+{
		jstring strObj = (*env)->NewStringUTF(env, "Hello World!");
		return strObj;
	}*/;

	public static void main(String[] args) {
		String str = HelloWorld.createString();
		System.out.println(str);
	}
}
@CType
package org.cni.examples;

import org.cni.annotation.CType;

public class SumIntegers {

	private @CType long	calculated;

	public native void calculateSum(int max)
	/*+{
		jlong sum = 0;
		for (int i = 0; i < max; i ++) {
			sum += i;
		}
		
		SumIntegers_set_calculated(env, self_arg, sum);
	}*/;

	public static void main(String[] args) {
		int max = (args.length == 1 ? Integer.parseInt(args[0]) : 1000000);

		SumIntegers worker = new SumIntegers();

		worker.calculateSum(max);

		System.out.println(worker.calculated);
	}
}