SHARE
TWEET

Untitled

a guest Aug 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from py4j.java_gateway import (
  2.     JavaGateway, CallbackServerParameters, GatewayParameters,
  3.     launch_gateway)
  4.  
  5. (port, token) = launch_gateway(enable_auth=True)
  6.  
  7. gateway = JavaGateway(
  8.     gateway_parameters=GatewayParameters(port=port, auth_token=token),
  9.     callback_server_parameters=CallbackServerParameters(port=0))
  10.  
  11. python_port = gateway.get_callback_server().get_listening_port()
  12.  
  13. gateway.java_gateway_server.resetCallbackClient(
  14.         gateway.java_gateway_server.getCallbackClient().getAddress(),
  15.             python_port)
  16.  
  17. gateway.close()
  18.  
  19. random = gateway.jvm.java.util.Random()
  20. print([random.nextInt(100) for _ in range(10)])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top