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`.

- 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 Functions
- 4.2. `py4j.protocol` — Py4J Protocol
  - 4.2.1. Py4JError
  - 4.2.2. Py4JJavaError
  - 4.2.3. Py4JJavaError
  - 4.2.4. Py4J Protocol Functions
- 4.3. `py4j.java_collections` — Py4J Collections API
  - 4.3.1. JavaIterator
  - 4.3.2. JavaList
  - 4.3.3. JavaMap
  - 4.3.4. JavaSet
  - 4.3.5. JavaArray
- 4.4. `py4j.finalizer` — Py4J Finalizer API
  - 4.4.1. ThreadSafeFinalizer
  - 4.4.2. Finalizer
  - 4.4.3. Py4J Finalizer Functions

### 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!

### Navigation

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