0

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?

toriningen
  • 7,196
  • 3
  • 46
  • 68
Abdul husein
  • 21
  • 1
  • 6

1 Answers1

1

I had to install the py4j application from http://py4j.sourceforge.net/install.html#install-instructions

Abdul husein
  • 21
  • 1
  • 6