Using libjclass in your application

The easiest way to compile an application with libjclass is by using the pkg-config utility. The following shell session shows how to compile a hello program with pkg-config.

Example 1. Compile hello.c that uses libjclass

cc `pkg-config --cflags --libs jclass` hello.c -o hello

If you don"t have pkg-config you can still use libjclass, but you will need a little more effort.

Example 2. Compile hello.c that uses libjclass on MinGW

jclassinfo is installed in jdir. gcc -Ijdir/include -Ljdir/lib -lc -lm -lz -ljclass -o hello.exe hello.c

Here"s the source code for a sample hello.c.

It loads the HelloWorld class, gets its fully qualified name and prints it.

#include <stdio.h>
#include <stdlib.h>
#include <jclass/jclass.h>

int main(int argc, char *argv[])
	JavaClass *helloWorld;

	helloWorld = jclass_class_new("HelloWorld", NULL, NULL);
	if (helloWorld)
		char *class_name;
		class_name = jclass_class_get_class_name(helloWorld);