Jython Overview
Jython is a Python implementation that runs on the Java Virtual Machine (JVM). It keeps the Python language familiar - the same syntax, standard library, and idiom - while letting you use Java classes, libraries, and frameworks directly from Python code. The classic Jython release (2.7.x) targets Python 2.7 semantics running on Java.
What Jython Is
- An alternative Python implementation: CPython runs on the CPython VM; IronPython on the CLR; Jython on the JVM.
- A Java integration layer: import and use java.* packages, implement Java interfaces, and subclass Java classes.
- A scripting tool for the Java world: glue code, automation, and rapid prototyping where Java is the host platform.
Why Use Jython?
- Access the entire Java ecosystem (hundreds of thousands of libraries) from concise Python code.
- Write JVM scripts without Java's verbosity - Jython is often 3-5x shorter than equivalent Java.
- Embed scripting into Java applications for user-facing extension points.
- Run on any machine with a JVM - the same script runs everywhere Java runs.
Jython vs CPython
| CPython | Jython | |
|---|---|---|
| Host | C runtime | JVM (Java) |
| Java interop | via JNI/bridges | native first-class imports |
| Performance (CPU-bound) | fast C extensions | pure Java execution; JIT helps |
| C extensions (numpy, etc.) | supported | not supported (no C ABI) |
| Threading | GIL-constrained | true parallel threads (no GIL) |
A First Example
import java.util
names = java.util.ArrayList()
names.add("Skillversitas")
print(names.get(0)) # Skillversitas
print(len(names)) # 1
That is the whole idea: Python syntax, Java types, zero ceremony.
Summary
Jython is Python on the JVM: the same language you know, plus first-class access to Java classes, collections, and frameworks. Choose it when your platform is Java and you want concise scripting, or when you need true multithreading without the GIL. C extensions do not work; the Java ecosystem does.