0

Is there any way I can check in Java if the String I'm receiving points to a valid Python installation directory?

The idea is to force the user to only give a valid path to his Python installation folder, and if the path is not valid, return an error to let them know.

Jesse James
  • 1,203
  • 5
  • 22
  • 39
  • This might be super hacky and probably breaks often but you could just run `python --version` from within your Java program and check the output. [Here](https://stackoverflow.com/questions/5711084/java-runtime-getruntime-getting-output-from-executing-a-command-line-program) you can find details about stuff you need. – akuzminykh Jun 30 '20 at 10:12

1 Answers1

0

This solution has a couple of problems. On *nix machines, there is not really such a thing as a installation directory.

So, instead of a directory, you might want the use to select an executable. This will also allow you to run a python --version to check if the version is ok.

Lennart Steinke
  • 584
  • 5
  • 11