-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

elyesjbl
  • 1
  • 1
  • 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? – Scary Wombat Apr 05 '22 at 00:41
  • Show code as properly formatted text in the question, not as image or external link. – Michael Butscher Apr 05 '22 at 00:41
  • Use the complete executable path of Python. Check this out: https://stackoverflow.com/a/55603110/15400163 – SM1312 Apr 05 '22 at 00:43
  • The creation of the file should take place relative to the "working directory", which likely where ever Eclipse executed the program from – MadProgrammer Apr 05 '22 at 00: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. – paladin Apr 05 '22 at 00:46
  • Please edit the question to include your code as ```Your Code``` to make it clear. Thanks! :) – Esraa Abdelmaksoud Apr 05 '22 at 01:28

1 Answers1

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.

rikyeah
  • 1,896
  • 4
  • 11
  • 21