Embed Python in JVM Applications with GraalPy

access icon

Python Packages in Java

Use Python packages directly in Java, Kotlin, or Scala
speed icon

Jython Upgrade Path

upgrade icon

JVM Scripting with Python

Script JVM applications with Python

How to Get Started

Add GraalPy as a dependency to your JVM application, or go straight to the starter project.

Without Python Dependencies

dependencies {
    implementation("org.graalvm.polyglot:polyglot:25.0.2")
    implementation("org.graalvm.polyglot:python:25.0.2")
}
import org.graalvm.polyglot.Context;

try (Context context = Context.newBuilder()
        .allowAllAccess(true) // See documentation for options
        .build()) {
    context.eval("python", "print('Hello from GraalPy!')");
}

With Python Dependencies

plugins {
    id "org.graalvm.python" version "25.0.2"
}

dependencies {
    implementation("org.graalvm.python:python-embedding:25.0.2")
}

graalPy {
    packages = ["pyfiglet==1.0.2"]
}
import org.graalvm.polyglot.Context;
import org.graalvm.python.embedding.GraalPyResources;

try (Context context = GraalPyResources.contextBuilder().build()) {
    context.eval("python", """
        from pyfiglet import Figlet
        f = Figlet(font='slant')
        print(f.renderText('Hello from GraalPy!'))
        """);
}

Videos

Tips and Tricks for GraalVM and Graal Languages

In this session, Fabio Niephaus from the GraalVM team shows his favourite tips and tricks for using GraalPy and other Graal Languages in IntelliJ IDEA. He also shows how to use IntelliJ IDEA as a multi-language IDE. Language injections and support for various debugging protocols make it easy to embed and debug code written in languages like Python in Java applications.

Supercharge your Java Applications with Python!
Jfokus'25

Projects such as LangChain4j, Spring AI, and llama3.java got the Java community very excited about AI in the last year. The Python ecosystem also provides many powerful packages for data science, machine learning, and more. Wouldn't it be cool if you, as a Java developer, could benefit from this, too?
In this talk, we show how you can get started with GraalPy and use packages from the Python ecosystem. We also show some live demos and preview upcoming features that will improve the interaction between Java and native extensions that ship with popular Python packages.