Can anyone help me ,,,,,,, ,,how I can combine Java and python at a single program ,,,,,,,,,,,,,,,or is it even possible | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone help me ,,,,,,, ,,how I can combine Java and python at a single program ,,,,,,,,,,,,,,,or is it even possible

Cuz I want to create super program,,,,,,, ,,,,, I wa nt to create AI like Tony Stark's Jarvis with my friends who are learning another language

12th Aug 2020, 3:30 AM
Sumit Sinha
Sumit Sinha - avatar
1 Answer
+ 1
You can do this by using one of the languages to execute the other through the command line: Python: # Using the `os` module: import os os.system("java -jar MyJarFile.jar") # Or (still with `os`): s = os.popen("java -jar MyJarFile.jar") output = s.read() print(output) # Prints output from running command. # Using the `subprocess` module (for a bit more control): import subprocess process = subprocess.Popen(['java', '-jar', 'MyJarFile.jar'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() Running python with java: See this: https://www.edureka.co/community/358/how-to-execute-a-python-file-with-few-arguments-in-java
12th Aug 2020, 3:48 AM
Brian R
Brian R - avatar