Step1 - I have created a jar out of sample java code- MyPythonGateway.jar
Java Class-
import py4j.GatewayServer;
public class MyPythonGateway{
public int findMyNum(String input){
return(1);
}
public static void main(String[] args){
GatewayServer server = new Gatewayserver(new MyPythonGateway())
server.start();
}
}
Step2- I am invoking pyspark by mentioning this jar- MyPythonGateway.jar in executor.extraClassPath and driver.extraClassPath
pyspark is launched well.
Step3- trying to invoke java code from pyspark now
Error: Py4jNetworkError: An Error occurred while trying to connect to the Java server (127.0.0.1:25335)
I used other ports also like- 25340 , 25338 but getting same error every time