Skip to content

scapix-com/example2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example for Scapix JNI

Scapix JNI is a modern C++20 wrapper for Java Native Interface (JNI). It provides type-safe APIs and automatic resource management, with ZERO runtime overhead compared to manually written JNI code.

// Generated C++ headers for all JDK/Android classes:

#include <scapix/java_api/java/lang/System.h>
#include <scapix/java_api/java/util/Locale.h>
#include <scapix/java_api/java/text/DateFormatSymbols.h>

namespace jni = scapix::jni;
using namespace scapix::java_api;

void example()
{
    // call any Java functions from any Java classes

    auto version = java::lang::System::getProperty("java.version");
    auto languages = java::util::Locale::getISOLanguages();
    auto zone_strings = java::text::DateFormatSymbols::getInstance()->getZoneStrings();
    auto properties = java::lang::System::getProperties();
}

Install and build this example (Windows, macOS, Linux)

$ git clone https://github.com/scapix-com/example2
$ cd example2
$ ./build.sh default