JEP – Java Embedded Python

Publication ID: ICY-88973

Short Description

Jep embeds CPython in Java through JNI.

Code on Python through Java !

Team: Bioimage Analysis Unit
Institution: Institut Pasteur


Some benefits of embedding CPython in a JVM:

  • Using the native Python interpreter may be much faster than alternatives.
  • Python is mature, well-supported, and well documented.
  • Access to high quality Python modules, both native CPython extensions and Python-based.
  • Compilers and assorted Python tools are as mature as the language.
  • Python is an interpreted language, enabling scripting of established Java code without requiring recompilation.
  • Both Java and Python are cross-platform, enabling deployment to different operating systems.

Installation instructions

Simply run pip install jep or download the source and run python build install. Building and installing require the JDK, Python, and optionally numpy to be installed beforehand.

On your Icy plugin project, add this dependency



  • Python >= 3.5
  • Java >= 1.8
  • NumPy >= 1.7 (optional)

Notable features

  • Interactive Jep console much like Python’s interactive console
  • Supports multiple, simultaneous, mostly sandboxes sub-interpreters or shared interpreters
  • Numpy support for Java primitive arrays


We welcome comments, contributions, bug reports, wiki documentation, etc.

If you need help, please first search for existing solutions online, in the issues, and on the wiki. If you still need help, please open a GitHub issue, and we will try and help you. Please remember to close the issue once it has been resolved.

Jep Team


Please also cite the Icy software and mention the version of Icy you used (bottom right corner of the GUI or first lines of the Output tab):
de Chaumont, F. et al. (2012) Icy: an open bioimage informatics platform for extended reproducible research, Nature Methods, 9, pp. 690-696


JEP Team Nate Jensen & Ben Steffensmeier

Plugin conversion Amandine Tournay


Until JEP 4.0.3, for Linux users, you need to set temporarily the environment variable LD_PRELOAD to your file.
It is due to some difficulties with Java and C projects that dlopen libraries.
It has been fixed for the next version planned for Fall 2022.

Utility functions

// Check if a String is a system path

// Get a list of Conda environments with their full path

// Get a list of only conda environment names

// Find the Python execution file by the root directory of Python or check the full path if it is given
PythonUtils.getInstance().findPythonExecutable("<path>", Boolean.TRUE || Boolean.FALSE);

// Retrieve the site-packages directory from the selected Python
PythonUtils.getInstance().setSitePackagesDirectory("<Python path>");

// Retrieve the running JEP file from the site-packages directory of the selected Python
 JepUtils.getInstance().findJepLib("<site-packages path>");

// Instantiate JEP
JepUtils.getInstance().setJepPath("<JEP path>", "<Python root path>");

// Open a Python instance (to use with a try-catch(JepException)
SubInterpreter python = JepUtils.getInstance().openSubPython();
// Same but adding a JEP configuration object to manage better the link between Java and Python (see JavaDoc)
SubInterpreter python2 = JepUtils.getInstance().openSubPython(new JepConfig());

// Running some Python code
python2.exec("x = 5");
python2.runScript("<Python script file path>");
// Prints 5
// Send data to Python
python2.set("y", 10);
// Prints 10 on the Python output stream
// Close a Python instance
// Always close an opened instance !

Leave a Review

Leave a review
Cancel review
View full changelog
Close changelog


  • Version • Released on: 2022-08-03 00:00:00