Autocomplete Java In Python using Py4J

Py4J provides a way to access Java objects from a Python interpreter. It can now be used to autocomplete Java objects from an interactive environment like PyDev, IPython or IPython Notebook.

DAWN uses Py4J as one of the technologies that provides integration of Java and Python for science. A great new feature of DAWN is the ability to record macros for scripting of plotting operations. Previously, objects in Java could not be auto-completed in the console even though they were accessible using Py4J.  We worked on extending Py4J (thanks to funding from DAWN & Diamond Light Source) to enable that feature and support the following:

  • Autocompletion of Java method and field names of class instances
  • Auto-generated pop-up help,  based on signatures, of Java methods

The changes were recently reviewed and we are happy to report that they are now part of Py4J and available for anyone to use to get autocompletion of Java from Python and make life easier for their users.