Skip to main content
NSP’s JVM probe attaches to any running Java process using the JVMTI (JVM Tool Interface) and JNI reflection APIs. It loads a native JVMTI agent into the target process, enumerates classes and fields, converts Java objects to the Substrate Schema Format (SSF), and makes the resulting state — and the application’s methods — available to your agent over the standard NSP API. This guide walks you through detecting a Java app, reading its state, discovering actions, executing JVM method calls, and interpreting results.
1

Prerequisites

Confirm the following before you begin:
  • NSP daemon installed and running on port 7842. Download from platform.nelieo.com/download.
  • JDK 11 or later installed on the host machine. The JVM probe requires the AttachAPI from tools.jar (JDK 11+). A JRE alone is not sufficient.
  • The target Java application is running. The daemon scans for processes every 5 seconds, so start your app before querying for it. This guide uses a generic Java GCS application as its primary example; the same steps apply to IntelliJ IDEA, Jenkins, SAP ERP, Eclipse, Elasticsearch, and any other JVM-based app.
  • Python 3.11+ and the NSP SDK installed.
2

Detect the Java App

Call /substrate/v1/apps to verify the daemon has classified your application as a JVM app. Look for "runtime": "jvm" in the response.
Example response for a Java GCS application:
You can also list apps with the Python SDK:
Expected output:
The first JVMTI attachment (cold probe) can take up to 60–90 seconds as the probe enumerates all loaded classes and builds the schema. Subsequent runs use the cached schema and attach in under two seconds. Watch probe_status progress from attachingcold_probeactive.
3

Read Java App State

Attach to the app by name and read state using dot-notation keys. The JVM probe normalises Java object fields into SSF, giving you typed access with get_int(), get_float(), get_str(), and get_bool().
Expected output:
4

Explore Available Actions

Iterate session.actions to see every action the JVM probe discovered for this application. The probe discovers both NSP-native actions defined in the schema registry and raw Java method invocation actions exposed via JNI reflection.
Example output for a Java GCS:
5

Execute a JVM Action

Use session.execute() to run actions on the Java app. Reversible actions (like set_mode) do not require a verify_expression. Irreversible actions (like take_off) require verify=True and a verify_expression — NSP enforces this safety gate automatically.
Expected output:
6

Handle the jvm_invoke_snapshot Field

When NSP executes a JVM action that invokes a Java method directly, the action response includes a jvm_invoke_snapshot field. This field contains a serialised snapshot of the Java object returned by the method call — useful when the method returns a complex object rather than a primitive.
Example jvm_invoke_snapshot output:
jvm_invoke_snapshot is null for actions that do not invoke a Java method directly. Always check result.success first — a True result with a null snapshot simply means the action completed without returning a value (i.e. the Java method returns void).
7

Cold Probe Timing and Confidence

JVMTI attachment involves loading a native agent into the JVM and performing class enumeration — this takes time on first run. Understanding the lifecycle helps you write robust agents.
The probe_status field progresses through these stages:JVM confidence typically stabilises at 0.93–0.97 once active. Actions are gated by confidence level: reversible_write requires >= 0.80; irreversible_write requires >= 0.95.

Full Workflow Example

The script below covers every step: detecting the app, reading state, listing actions, executing both reversible and irreversible actions, and streaming live telemetry.