0

I've a Python program which just prints "hello world". I only want to get that output in a Java program and print that again, i.e. I want to consume output of Python program in a Java program.

I tried using Runtime.getRuntime().exec("helloworld.py"); but it is giving an exception saying java.lang.IOException : Cannot run program "helloworld.py" : CreateProcess error=193, %1 is not a valid Win32 application.

Can anybody please explain why this exception has occurred and what is solution for it ?

Thanks in advance!

Amol.Shaligram
  • 713
  • 1
  • 5
  • 12

2 Answers2

0

Have you tried this,

Runtime.getRuntime().exec("python helloworld.py");

Please try and if it doesn't work leave a comment.

Nikhil.Nixel
  • 555
  • 2
  • 11
  • 25
-1

Your file "helloworld.py" isn't a executable file.

Your command allow to run a prompt command.

try : Runtime.getRuntime().exec("python helloworld.py");

or see more : How do I run a Python program?

Jim Kiley
  • 3,632
  • 3
  • 26
  • 43
Zasalamel
  • 1
  • 1