Compile and run TestApplication.java with py4j.jar in your classpath.
Then execute python3 test.py
This creates three pairs of GatewayServer and CallbackServer with different ports on both the Java and Python sides. Python is driving the communication by asking Java to print