-1

This is my java code that let me execute a python script. The problem is everything is printed in the correct form but there is no creation for the file "test.txt" while executing with java. java script python script

If executing python script manually or from the cmd directly, everything works perfectly but not with java code

6
  • 3
    a) do not post code as images. b) do not silently ignore exceptions c) I do not think there is a python program, at least python.exe d) where do you expect test.txt to be created and why? Commented Apr 5, 2022 at 0:41
  • Show code as properly formatted text in the question, not as image or external link. Commented Apr 5, 2022 at 0:41
  • Use the complete executable path of Python. Check this out: stackoverflow.com/a/55603110/15400163 Commented Apr 5, 2022 at 0:43
  • The creation of the file should take place relative to the "working directory", which likely where ever Eclipse executed the program from Commented Apr 5, 2022 at 0:45
  • Don't write your entire program within the try block and you might see the error by yourself. This is very bad programming style. Commented Apr 5, 2022 at 0:46

1 Answer 1

0

Correct your cmd /c python with your correct python path (i can't know for sure that, but it will sure end with python.exe, not just python).

You don't see errors because you are catching exceptions (generate for example by a wrong path) without handling them, rendering them silent.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.