Install Javonet for Python

Javonet is available as a Python package, which can be installed using PyPI package manager or any other method which supports Python packages. For applications using Python 3.6 and higher use javonet-python-sdk 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.

from javonet.sdk import 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.

netcore_runtime = Javonet.in_memory().netcore()

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:

netcore_type = netcore_runtime.get_type("System.Math").execute()

And then get static field from the type:

response = netcore_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:

result = response.get_value()
print(result)

To sum up, the whole code snippet looks like:

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

# <RuntimeContextCreation>
netcore_runtime = Javonet.in_memory().netcore()
# </RuntimeContextCreation>

# <GetType>
netcore_type = netcore_runtime.get_type("System.Math").execute()
# </GetType>

# <GetStaticField>
response = netcore_type.get_static_field("PI").execute()
# </GetStaticField>

# <GetValue>
result = response.get_value()
print(result)
# </GetValue>