Executing Java File using Command Line in Streamlit Cloud

Hi there,

I’m running a script from CMD
using the following code

command = "java -jar DescriptorsGeneratorCLI-1.0.0.jar {}".format(smiles)
generated_descriptors = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout

It runs successfully locally, however when deploying it streamlit cloud, it gives me the following error.

FileNotFoundError: [Errno 2] No such file or directory: ‘java -jar DescriptorsGeneratorCLI-1.0.0.jar C(=O)(N)NOC’

I installed Java using packages.txt, and everything is pushed to GitHub repo.

How to fix that problem?, I think it’s not recognizing Java from the terminal.

Appreciated

Hello, @Ahmed_Hammad, and welcome to our community!

I’m actually not sure whether it’s possible to use such a command with Community Cloud.

I’ll double-check with the devs now.

Thanks,
Charly

Hi @Ahmed_Hammad

I’ve checked with the devs, and this isn’t currently supported.

What is/are your use case(s)?

I appreciate your efforts @Charly_Wargnier
Basically I have a Java class that returns list of items, I’m using this list in my python code, so one solution was to run the java code in terminal by python (using subprocess.run).
Since this is not working, I have to find a better way to integrate java with python.

Do you have any suggestion? and should I leave the this forum open?

Thanks again @Charly_Wargnier

Some options:
[1] If you have the java source code, then suggest you convert it to python and run that directly in your app.
[2] Wrap the java functionality in an API and deploy the API in another cloud service. Call that API from Streamlit.

[1] >> [2]

Arvindra

Thank you for the fast response!
Appreciated a lot

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.