Java Link

scapix::link::java library provides C++ interface to JNI (Java Native Interface) API. It may be used on it’s own in any application, or in a platform dependent part of an application utilizing Scapix Language Bridge.

Example using generic API (without generated headers):

#include <scapix/link/java/object.h>

using namespace scapix::link::java;

void test_string()
{
    auto str = object<SCAPIX_META_STRING("java/lang/String")>::new_object();
    auto length = str->call_method<SCAPIX_META_STRING("length"), jint()>();
}

Same code using headers generated by scapix_java utility:

#include <scapix/java_api/java/lang/String.h>

using namespace scapix::java_api;

void test_string()
{
    auto str = java::lang::String::new_object();
    auto length = str->length();
}

In both cases, scapix::link::java library automatically takes care of all JNI resource management and JVM exceptions processing.