Skip to main content

Documentation Index

Fetch the complete documentation index at: https://ray-preview.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Ray supports Python, Java, and C++ as first-class languages. A single cluster can host workers from all three, and tasks can call across language boundaries.

Enable cross-language support

Cross-language code-paths are off by default in Python. Initialize the runtime with code_search_path pointing at your jar/binary directories.
ray.init(
    job_config=ray.job_config.JobConfig(
        code_search_path=["/path/to/jars/*", "/path/to/cpp_libs"]
    )
)

Call Java from Python

import ray
counter = ray.cross_language.java_actor_class("io.ray.example.Counter").remote()
ref = counter.increment.remote()
print(ray.get(ref))
from ray import cross_language

func = cross_language.java_function("io.ray.example.Math", "add")
print(ray.get(func.remote(1, 2)))

Call C++ from Python

from ray import cross_language

cls = cross_language.cpp_actor_class(name="Counter", function_name="CreateCounter")
counter = cls.remote()
print(ray.get(counter.Increment.remote()))

Argument types

Cross-language calls support primitives, byte strings, and protocol buffers. Pass complex objects via the object store.

Limitations

  • Decorators like @ray.remote are Python-only; the Java and C++ APIs are equivalent but distinct.
  • Stack traces don’t cross language boundaries automatically.
  • Java and C++ actors don’t support every option available to Python actors.

Next steps

Java API

Java API reference.

C++ API

C++ API reference.