Install Javonet for Perl

Javonet is available as a Perl package, which can be installed using CPANM package manager or any other method which supports Perl packages. For applications using Perl 5 use JavonetPerlSdk Package

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.

use aliased 'Javonet::Javonet' => 'Javonet';

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.

my $python_runtime = Javonet->in_memory()->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:

my $python_type = $python_runtime->get_type("math")->execute();

And then get static field from the type:

my $response = $python_type->get_static_field("pi")->execute();

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

my $result = $response->get_value();
print("$result\n");

To sum up, the whole code snippet looks like:

# <Activation>
Javonet->activate("your-license-key");
# </Activation>

# <RuntimeContextCreation>
my $python_runtime = Javonet->in_memory()->python();
# </RuntimeContextCreation>

# <GetType>
my $python_type = $python_runtime->get_type("math")->execute();
# </GetType>

# <GetStaticField>
my $response = $python_type->get_static_field("pi")->execute();
# </GetStaticField>

# <GetValue>
my $result = $response->get_value();
print("$result\n");
# </GetValue>