I am trying to test calling a java program from Python using py4j
. I have installed the plugin in Eclipse and created pydev project named test. I am trying to execute the following piece of code I found on the py4j webpage:
from py4j.java_gateway import JavaGateway, java_import
gateway = JavaGateway()
jvm = gateway.jvm
java_import(jvm, 'org.eclipse.core.resources.*')
workspace_root = jvm.ResourcesPlugin.getWorkspace().getRoot()
gateway.help(workspace_root, '*Projects*')
project_names = [project.getName() for project in workspace_root.getProjects()]
print(project_names)
But I get an error in the import. I have checked that the py4j jar is present in the plugins directory of Eclipse. Can someone please help?