Writing client scripts for JEB2 using Python

The latest release of JEB2, version 2.0.14, introduces a feature familiar to JEB1 users: client scripts written in Python.

Both Standard and Business licenses permit running scripts. They can be written using the Python 2.5 or 2.7 syntax and features, and are executed by Jython. (A Jython stand-alone package is required to run scripts. We recommend version 2.5. Download it and drop it in your JEB2 scripts/ sub-directory.)

Feature-wise, scripts use the standard JEB2 core APIs. They are also using the client API, available in the com.pnfsoftware.jeb.client.api package. As usual, refer to our Developer Portal and Javadoc website for API reference and usage.

A client script implements the IScript interface. Upon execution, the script run() entry-point method is provided an IClientContext or derived object, such as an IGraphicalClientContext for UI clients. (The official RCP desktop client falls in the latter category.)

Here is the simplest of all scripts:

from com.pnfsoftware.jeb.client.api import IScript
class JEB2SampleScript(IScript):
  def run(self, ctx):
    print('Hello, JEB2')

Within the official desktop client, scripts can be executed via the File, Scripts menu item.

Finally, remember that scripts are meant to execute small, light-weight actions. Heavy lifting operations (such as parsing or background event-driven tasks) should be implemented by back-end plugins in Java.

Check out our GitHub repository for more sample scripts.

Published by

Nicolas Falliere

Author of JEB.

2 thoughts on “Writing client scripts for JEB2 using Python”

    1. 不知周末还是咋的,竟然没人回应,看文档后自己做出来了,贴到这里供有需要的人参考。。。

      codeItem = codeNode.getObject()
      codeClass = codeItem.getImplementingClass()

      actCntx = ActionContext(unit, Actions.RENAME, codeClass.getItemId(), codeClass.getAddress())
      actData = ActionRenameData()
      actData.setNewName(newClassName)

      if(unit.prepareExecution(actCntx, actData)):
      try:
      bRlt = unit.executeAction(actCntx, actData)
      if(not bRlt):
      print(u’executeAction fail!’)
      except Exception,e:
      print Exception,”:”,e

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

*