A comprehensive Python-to-Java bridge enabling seamless integration between Python and Java virtual machines
npx @tessl/cli install tessl/pypi-jpype1@1.6.0A comprehensive Python-to-Java bridge enabling seamless integration between Python and Java virtual machines through native-level interfacing. JPype1 allows Python applications to access Java libraries, execute Java code, and manipulate Java objects directly within Python environments without requiring code re-implementation.
pip install JPype1import jpypeCommon import patterns:
# For JVM lifecycle management
from jpype import startJVM, shutdownJVM, isJVMStarted
# For Java class and object access
from jpype import JClass, JObject, java, javax
# For type bridging
from jpype import JString, JArray, JInt, JDoubleimport jpype
from jpype import java, javax
# Start the JVM
jpype.startJVM()
# Access Java classes through java/javax packages
String = java.lang.String
System = java.lang.System
ArrayList = java.util.ArrayList
# Create and use Java objects
hello = String("Hello from Java!")
print(hello.length()) # Call Java method
print(hello.toUpperCase())
# Work with collections
list_obj = ArrayList()
list_obj.add("Python")
list_obj.add("Java")
print(f"List size: {list_obj.size()}")
# Access system properties
System.out.println("Hello from Python via Java!")
java_version = System.getProperty("java.version")
print(f"Java version: {java_version}")
# Always shutdown when done
jpype.shutdownJVM()JPype1 bridges Python and Java through a native shared-memory architecture:
The design enables access to the entirety of both CPython and Java ecosystems while maintaining high performance through native integration rather than serialization or process boundaries.
Core functionality for starting, configuring, and managing the Java Virtual Machine from within Python applications. Includes JVM discovery, startup configuration, and shutdown procedures.
def startJVM(*jvmargs, **kwargs): ...
def shutdownJVM(): ...
def isJVMStarted() -> bool: ...
def getJVMVersion() -> tuple: ...
def getDefaultJVMPath() -> str: ...Access and manipulation of Java classes, objects, and packages through Python interfaces. Provides structured access to Java APIs and seamless object interoperability.
class JClass: ...
class JObject: ...
class JPackage: ...
def JInterface: ...
java: JPackage # Global java.* package access
javax: JPackage # Global javax.* package accessComprehensive type bridging between Python and Java type systems, including primitive types, arrays, strings, and custom type conversions.
class JString: ...
class JArray: ...
class JBoolean: ...
class JByte: ...
class JChar: ...
class JShort: ...
class JInt: ...
class JLong: ...
class JFloat: ...
class JDouble: ...Create Python implementations of Java interfaces and proxy objects for bidirectional communication between Python and Java code.
class JImplements: ...
class JProxy: ...
def JOverride: ...Handle Java exceptions within Python and bridge between Python and Java exception systems.
class JException(Exception): ...Manage Java classpath, configure import paths, and customize class loading behavior for Python-Java integration.
def addClassPath(path): ...
def getClassPath(env=True) -> list: ...Specialized functionality including threading support, GUI integration, NIO buffer support, customization framework, and database API integration.
def synchronized(obj): ...
def attachThreadToJVM(): ...
def detachThreadFromJVM(): ...
def convertToDirectBuffer(obj): ...