I've recently discovered py4j and was able to call static java methods from python. Now I want to call python methods from java. I couldn't find much documentation so this is the last place I can think of that might tell me if it's possible, and how.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can call a Python method from Java by implementing a Java interface on the python side.
The steps are:
gateway = JavaGateway(start_callback_server=True)
Example adapted from the Py4J documentation:
Java code:
Python code: