Install Javonet for C++

Javonet is available as a dynamic c++ library and can be downloaded after registering.

Activate Javonet

Use register or log in pages to obtain license key. An e-mail and license key is necessary to activate Javonet.

First sample application

Javonet needs to be imported as any other dependency.

#include "Javonet.h"

Javonet needs to be activated first. Activation must be called only once at the start-up of an application. During the first activation, license server are called and a javonet.lic file is generated.

Javonet::Activate("your-license-key");

To use other programming technology, Runtime Context of the called technology needs to be created.

auto pythonRuntime = Javonet::InMemory()->Python();

RuntimeContext refers to single instance of the called runtime. Once it is created it is used to interact with called runtime. The simplest use case is to get from target technology a type from a built-in library:

auto pythonType = pythonRuntime->GetType("math")->Execute();

And then get static field from the type:

auto response = pythonType->GetStaticField("pi")->Execute();

The returned value needs to be cast to calling technology type and can be used as any other variable:

auto result = std::any_cast<float>(response->GetValue());
std::cout << result << std::endl;

To sum up, the whole code snippet looks like:

// <Activation>
Javonet::Activate("your-license-key");
// </Activation>

// <RuntimeContextCreation>
auto pythonRuntime = Javonet::InMemory()->Python();
// </RuntimeContextCreation>

// <GetType>
auto pythonType = pythonRuntime->GetType("math")->Execute();
// </GetType>

// <GetStaticField>
auto response = pythonType->GetStaticField("pi")->Execute();
// </GetStaticField>

// <GetValue>
auto result = std::any_cast<float>(response->GetValue());
std::cout << result << std::endl;
// </GetValue>