How to detect from Java if Python is installed

3 weeks ago 18
ARTICLE AD BOX

Currently, I am developing a project made in Java and, due to circumstances, I need to know if Python is installed on the system. This is to execute the correct version of a tool/library. The tool I want to use is Esptool, which is a library for Python, but it also has a compiled version for Windows, Mac, and Linux. Therefore, I need to know if Python is installed so that, in case the compiled version of Esptool is not compatible with the system, I can execute the Python version instead. However, I don’t know how to do this. I hope someone can help me.

P.S.: I thought about doing it by detecting the response returned by running python --version, but I don’t know how to handle that response or if there is another way to determine whether Python is installed on the system that fits with what was mentioned above.

P.S.2: The compiled version of Esptool supports 64-bit Windows, macOS with Intel and Apple Silicon, and Linux on arm64, arm32, and x86_64 (amd64), while the Python version supports all of the above, including 32-bit versions.

Read Entire Article