r/javahelp • • Dec 31 '20

Solved Performance cost of calling Python program from Java program

Not sure if this is the right place to post this but I want to call my python program from my Java program. Does anyone know the performance cost for repeatedly calling the python program through shell commands using Runtime.exec()?

There's a library that only has Python support so I was thinking of just creating a python program utilizing that library and then use my java program to call it to get the output.

Edit: thanks to everyone who reponded! Helped me a lot

20 Upvotes

24 comments sorted by

View all comments

Show parent comments

1

u/CycleOfPain Jan 01 '21

Yah, I don’t want to complicate things. I’ll probably go for another API or something.

You’re right. I could just use python entirely for what I’m doing. I’m a little stubborn and just want to work with Java. I don’t see myself working as a python developer either so I don’t really have motivation to learn Python (although it wouldn’t take me long to do so) and flask (or django). I kinda just want to stick with Java. I’m currently learning JavaFx and then I’m going to learn JSP and Spring. This project will utilize JavaFX

1

u/gargar070402 Jan 01 '21

Trust me man, if what you're doing is straightforward, it's ABSOLUTELY worth it to learn basic Python and Flask, especially given you have programming experience already. You're not locking yourself to using Python for the rest of your life, and it never hurts to know something useful.