Implementation:Ray project Ray Ray Init For Actors
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Computing, Actor_Model |
| Last Updated | 2026-02-13 17:00 GMT |
Overview
Concrete tool for initializing the Ray runtime for actor lifecycle operations provided by the Ray Java SDK.
Description
The same Ray.init() method used for task execution, documented here in the actor lifecycle context. After initialization, the runtime supports Ray.actor() for creating actors, handle.task() for invoking actor methods, Ray.getActor() for named actor lookup, and handle.kill() / Ray.exitActor() for termination.
Usage
Call Ray.init() before any actor creation or management operations. The initialization is a one-time operation shared across task and actor workflows within the same JVM process.
Code Reference
Source Location
- Repository: ray-project/ray
- File: java/api/src/main/java/io/ray/api/Ray.java
- Lines: L15-34
Signature
public static void init()
Import
import io.ray.api.Ray;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | — | — | Zero-argument method. |
Outputs
| Name | Type | Description |
|---|---|---|
| Ray.runtime | RayRuntime | Initialized runtime supporting actor operations |
Usage Examples
Initialize for Actor Usage
import io.ray.api.Ray;
import io.ray.api.ActorHandle;
public class ActorApp {
public static class Counter {
private int value = 0;
public int increment() { return ++value; }
}
public static void main(String[] args) {
// Initialize Ray — required before actor creation
Ray.init();
ActorHandle<Counter> counter = Ray.actor(Counter::new).remote();
// ... use actor ...
Ray.shutdown();
}
}