Py4J - A Bridge between Python and Java

### Navigation

- index
- modules |
- next |
- previous |
- Home |
- Download |
- Doc |
- Blog |
- github |
- About »

# 4. Py4J Python API

Using Py4J is usually as simple as creating a JavaGateway object:

    java_gateway = JavaGateway()
    # you are now connected to the JVM
    # and you can call any method defined on the Java side.

You can still customize and extend Py4J in many ways (e.g., you can choose the port to which you want to connect). The following modules are documented. Note that users are expected to only use `py4j.java_gateway` or `py4j.clientserver`.

- 4.1. `py4j.java_gateway` — Py4J Main API
  - 4.1.1. JavaGateway
    - 4.1.1.1. Examples
  - 4.1.2. GatewayParameters
  - 4.1.3. CallbackServerParameters
  - 4.1.4. GatewayClient
  - 4.1.5. GatewayConnection
  - 4.1.6. JVMView
  - 4.1.7. JavaObject
  - 4.1.8. JavaMember
  - 4.1.9. JavaClass
  - 4.1.10. JavaPackage
  - 4.1.11. PythonProxyPool
  - 4.1.12. CallbackServer
  - 4.1.13. CallbackConnection
  - 4.1.14. Py4J Core Signals
  - 4.1.15. Py4J Functions
- 4.2. `py4j.clientserver` — Py4J Single Threading Model Implementation
  - 4.2.1. ClientServer
    - 4.2.1.1. Examples
  - 4.2.2. JavaParameters
  - 4.2.3. PythonParameters
  - 4.2.4. JavaClient
  - 4.2.5. PythonServer
  - 4.2.6. ClientServerConnection
- 4.3. `py4j.protocol` — Py4J Protocol
  - 4.3.1. Py4JError
  - 4.3.2. Py4JJavaError
  - 4.3.3. Py4JJavaError
  - 4.3.4. Py4J Protocol Functions
- 4.4. `py4j.java_collections` — Py4J Collections API
  - 4.4.1. JavaIterator
  - 4.4.2. JavaList
  - 4.4.3. JavaMap
  - 4.4.4. JavaSet
  - 4.4.5. JavaArray
- 4.5. `py4j.finalizer` — Py4J Finalizer API
  - 4.5.1. ThreadSafeFinalizer
  - 4.5.2. Finalizer
  - 4.5.3. Py4J Finalizer Functions
- 4.6. `py4j.signals` — Py4J Signals API
  - 4.6.1. Signal

### Questions/Feedback?

- Try the FAQ -- It answers many questions.
- Search for information in the archives of the py4j-users mailing list, or post a question.
- If you notice errors with this documentation, open a ticket and let us know. Please, only open a ticket for feedback or improvements on the docs. To get help, use the links above!
- Request professional services to get a custom feature implemented quickly or to receive commercial support.

### Navigation

- index
- modules |
- next |
- previous |
- Home |
- Download |
- Doc |
- Blog |
- github |
- About »