Apertus
  • Documentation
  • Introduction
    • Definitions
      • Coordinate systems
      • Primitives
    • Features
      • Basic
        • Nodes
        • Light sources
        • Geometries
        • Primitives
        • Texts
      • Environment simulation
        • Water
        • Sky
        • Terrain
      • Browser
      • UI technologies
        • HTML UI
        • Presentation
        • Gallery
      • PointCloud
      • 360
        • 360 Images
        • 360 Videos
      • 3D Model Formats
      • Scene Sharing
        • Multiplayer
      • Video and Voice Chat
      • Hand Tarcking
        • Leap Motion
      • Head Tracking
        • Fob
      • Displays
        • Multi Display
        • Cave System
        • HMDs
      • Industry
        • IoT, and Sensors
        • Robot monitoring
        • Robot calibration
  • Developers
    • Development Cycle
    • Architecture
      • Project folders
      • Configuration ecosystem
    • API
      • C++ API
      • JavaScript API
      • HTTP REST API
    • Getting Started
      • Creating a plugin
      • Creating a sample
  • Contribute
    • Report a Bug
    • Suggest a Feature
  • Tutorial - How to visualize CAD models in VR
    • Introduction
    • Import CAD Models
    • Convert CAD Models
    • Create Low-poly from CAD Models
    • Create Photorealistic CAD Models
  • Plugins - Photorealistic Render
  • Plugins - Physics
  • Tutorial - How to visualize Tensorflow training in VR
  • Tutorial - Virtual Learning Factory Toolkit Gamification
  • Overview
    • Introduction
    • Architecture
    • Use Cases
  • Installation
    • Windows
    • Android
      • How to use
      • Writing an application
    • MacOS
  • Build
    • Windows
      • How to build the source on Windows
    • Android
    • MacOS
  • Plugins on Windows
    • Photorealistic Render
      • How to use
      • How to configure
      • Features
      • Sample
    • Physics
      • How to use
      • How to configure
      • Features
      • Samples
      • Demo video
  • Plugins on Android
    • Java Native Interface
      • How to use
      • Extending the API
    • Filament render
      • How to use
      • How to configure
      • Developers
  • Plugins on MacOS
    • Untitled
  • Samples on Windows
    • Deep learning
      • Untitled
      • Use the Fastai-PythorchVR Sample
      • Use the HTTP API
      • Create HTTP Requests from Python
      • Demo video
    • Virtual Learning Factory Toolkit Gamification
      • Installation
      • Lobby - User Interface
      • Local - User Interface
      • Student - User Interface
      • Teacher - User Interface
      • VLFT Gamification Session
      • VR Mode
  • Virtual Learning Factory Application
    • Installation on Windows
    • Installation on Apple
    • Lobby
    • Single Player
    • Multi Player - Student
    • Multi Player - Teacher
Powered by GitBook
On this page
  • The Java Native Interface
  • Overview of the plugin
  1. Plugins on Android

Java Native Interface

This chapter introduces the JNI-Plugin, which is responsible for supporting the Java when using the ApertusVR library, and is used by the Android apps to cooperate with ApertusVR.

PreviousDemo videoNextHow to use

Last updated 4 years ago

The Java Native Interface

The Java Native Interface (JNI) is a native language support, which allows Java code (running on JVM) to interoperate with applications and libraries written in C and C++. JNI provides a one-way access to call C/C++ functions from Java. Therefore it helps to use ApertusVR's features from Java codes, which is indispensably important, when programming on Android.

Overview of the plugin

ApertusVR uses the JNI language support as a plugin, which helps distribute the events, and implements wrapper functionality for ApertusVR entities. The JNI-plugin consists of three layers:

  1. The C++ layer (apeJNIPlugin shared library)

  2. Java static native functions (ApertusJNI.java)

  3. Wrapper classes (ape<CppClassName>.java)

1. The C++ layer

This layer is an ordinary ape::IPlugin implementation, which gather the events into its event queue, then when somebody calls the appropriate function in Java (ApertusJNI.processEventDoubleQueue()), the plugin fires the events on the Java side, using the JNI's callback possibilities.

2. ApertusJNI

This is a static Java class, which contains the Java "headers" of the C++ JNI functions, and everything else needed to use the plugin in Java.

3. Wrapper classes

For each subclass of ape::Entity in ApertusVR, there is a corresponding Java class (the ape::Entity is also included), which provides an interface to access, query, and modify an object on the C++ side. These wrapper classes contains only a String, and a apeEntity.Type member variables, which makes it available to identify the entity related to the interface object. Then it calls the static nativefunctions in ApertusJNI, to access the entity in C++.

To learn more about the JNI interface see the official documentation on . For an easy to follow tutorial check .

Oracle's website
NTU Signapore's guide