I dug the internet a lot and found the solution.

One can do this using the following commands:

String fetching = "python " + "c:\\Fetch.py \"" + songDetails + "\"";
String[] commandToExecute = new String[]{"cmd.exe", "/c", fetching};
Runtime.getRuntime().exec(commandToExecute);
Answer from metamemelord on Stack Overflow
🌐
Reddit
reddit.com › r/springboot › execute python script from spring boot
r/SpringBoot on Reddit: Execute Python script from Spring boot
November 29, 2023 - try{ ProcessBuilder processBuilder = new ProcessBuilder("C:\\Users\\abc\\anaconda3\\python.exe", "./someScript.py"); // first arg is the path to your Python and second arg is the path to your py script processBuilder.redirectErrorStream(true); // redirect errors to the same stream Process process = processBuilder.start(); int exitCode = process.waitFor(); if (exitCode != 0) { log.error("Error: Python script exited with code " + exitCode); } } catch (Exception e) { e.printStackTrace(); log.error("Error while running Python script: " + e.getMessage()); } ... I wrote how to call a bash script using groovy years ago. It's not exactly what you're asking but you may find some inspiration. https://www.jcfrancisco.dev/posts/testing-scripts-with-groovy/ Spring Boot Best Practices That Should Fail Your Build
Discussions

Run python script
Hello everyone, I am trying to execute a python script from a spring boot project. I tried the following and seems like it is not working even though I am not getting any error. Could some one guide on a way to do the task? here is what i tried. package Python; import org.camunda.bpm.engin... More on forum.camunda.io
🌐 forum.camunda.io
0
1
May 19, 2021
How to call an internal Python service for a Java-based Spring Boot project - Stack Overflow
I have to execute a Python script from the inside of a Spring Boot project. The script should be pretty easy but was made by other people and if possible I want to avoid the needing of change it. ... From my Java code I execute a shell command, something like shown here: https://www.baeldung.com/run... More on stackoverflow.com
🌐 stackoverflow.com
July 31, 2020
Running Python Script with WebApp with Spring Boot Backend
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
3
2
December 4, 2024
[ask] how to communicate with python with spring boot.
Hello sir. This term I wanna develop a project with both python and java. I'd like to use spring boot to do the web part, but there's a tough problem for me. I 've already finish the da... More on github.com
🌐 github.com
5
April 6, 2019
🌐
Medium
jxausea.medium.com › spring-boot-integrated-python-engine-quick-start-demo-24d3f96cc4aa
Spring boot integrated python engine quick start demo | by Harries | Medium
March 12, 2024 - package com.et.python; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
🌐
GitHub
github.com › amemifra › Spring-Jython
GitHub - amemifra/Spring-Jython: Java integration of Python script and classes into a Spring Boot Web Application. Powered by Jython · GitHub
Before start: Open VS Code press f5 to autoattach the java debugger and start the Spring Boot Application.
Starred by 12 users
Forked by 11 users
Languages   Python 99.3% | Java 0.7%
🌐
Camunda
forum.camunda.io › camunda 7 topics › discussion & questions
Run python script - Discussion & Questions - Camunda Forum
May 19, 2021 - Hello everyone, I am trying to execute a python script from a spring boot project. I tried the following and seems like it is not working even though I am not getting any error. Could some one guide on a way to do the task? here is what i tried. package Python; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; public class RunPythonScript implements JavaDelegate{ @Override public void execute(DelegateExecution execution) throws...
🌐
YouTube
youtube.com › vlogize
How to Execute a Python Script in Spring Boot with GraalVM - YouTube
Discover the solution to integrating `Python` scripts using `GraalVM` in your `Spring Boot` application, including code snippets and debugging tips.---This v...
Published   March 30, 2025
Views   2
Find elsewhere
🌐
Dreamix
dreamix.eu › home › insights › tech › how to use jython with spring boot
How to use Jython with Spring Boot - Dreamix
July 16, 2024 - I used the first one in the Spring tutorial - https://spring.io/guides/gs/spring-boot/ 2.Then we need Jython (https://www.jython.org/ ). I installed version 2.7.1 to my PC and added the dependency to the pom.xml like that: <dependency> <groupId>org.python</groupId> <artifactId>jython</artifactId> <version>2.7.1</version> </dependency> An easier way would be to use jython-standalone artifact here which doesn’t require Jython installation and keeps most of the libraries in the JAR but it has limited functionality and doesn’t allow you to use external modules available through pip.
🌐
Reddit
reddit.com › r/javahelp › running python script with webapp with spring boot backend
r/javahelp on Reddit: Running Python Script with WebApp with Spring Boot Backend
December 4, 2024 -

Hello everyone.. i want to ask is it possible to add a python script like this?

I have a functional spring boot + react app for users and they already using it. But they have a new change request to add a button to download the file as an excel with templates and data was fetch from the db. My friend help me by building a python script to generate this file (since we think python is good for working with data)

Is it possible to add a button in my react front end to run the python script and download the data as excel?

Top answer
1 of 2
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2 of 2
1
JYthon is a Java implementation of python 2.7. Beyond that, you're into executing an external process from your Spring backend. https://www.baeldung.com/java-process-api Either way is probably a lot more hassle than simply re-writing that Python in Java. I guess a third approach would be to turn that python script into a web app using Flask or something, and have your Spring backend call it. But it's all a lot of fuss, with you now having to manage failure modes which simply wouldn't happen if it was all done in-process. Having some Java do it natively in the Spring backend is far simpler. Apache POI makes working with Excel easier, and I think there are other libraries around.
🌐
GitHub
github.com › hendisantika › ask-me-anything › issues › 3
[ask] how to communicate with python with spring boot. · Issue #3 · hendisantika/ask-me-anything
April 6, 2019 - Hello sir. This term I wanna develop a project with both python and java. I'd like to use spring boot to do the web part, but there's a tough problem for me. I 've already finish the da...
Author   hendisantika
🌐
Spring
docs.spring.io › spring-python › 1.2.x › sphinx › html › remoting.html
8. Remoting — Spring Python v1.2.1.FINAL documentation
Running the remote service on another server only requires us to edit the client’s application context, changing the URL to get to the service. All without telling the client and server code. No. Again, Spring Python provides you the freedom to do things using the IoC container, or programmatically. To do the same configuration as shown above looks like this: from springpython.remoting.pyro import PyroServiceExporter from springpython.remoting.pyro import PyroProxyFactory # Create the service remoteService = Service() # Export it via Pyro using Spring Python's utility classes service_exporter = PyroServiceExporter() service_exporter.service_name = "ServiceName" service_exporter.service = remoteService service_exporter.after_properties_set() # Get a handle on a client-side proxy that will remotely call the service.
🌐
Baeldung
baeldung.com › home › java › how to call python from java
How to Call Python From Java | Baeldung
August 27, 2025 - Learn the most common ways of calling Python code from Java.
🌐
Quora
quora.com › How-do-I-call-Python-script-from-Java
How to call Python script from Java - Quora
Answer (1 of 4): The old approach. [code]Process p = Runtime.getRuntime().exec("python yourapp.py"); [/code]You can read up on how to actually read the output here: http://www.devdaily.com/java/edu/pj/pj010016 There is also an Apache library (the Apache exec project) that can help you with thi...
🌐
Stack Overflow
stackoverflow.com › questions › 73478757 › how-do-i-execute-a-python-script-from-java-spring-boot-web-application-controlle
How do I execute a python script from Java Spring Boot web application controller on AWS Elastic Beanstalk? - Stack Overflow
I have solved the path problem , I put the file under the resources folder , and I found that I just need to read the file through classPathResource.getInputStream() , and generate a temporary file in the root directory to get the path . ... Now I can run python scripts in Elastic Beanstalk, but can't use python suite, it gives error like this: Traceback (most recent call last): File "/var/app/current/application.py", line 1, in import numpy as np ModuleNotFoundError: No module named 'numpy'.
🌐
GitHub
github.com › GoogleContainerTools › jib › issues › 4185
Hi, I am trying to call the python script from Spring boot Java application which is containerized with Google Jib. · Issue #4185 · GoogleContainerTools/jib
February 13, 2024 - I am trying to call a python script for some business purposes which is containerized with Google Jib. I would like to know how can I copy python into the jib if it's possible , so that it will allow me to call the script from the applic...
Author   GoogleContainerTools
🌐
YouTube
youtube.com › watch
Empower your Spring Applications with Python Features on GraalVM by Johannes Link @ Spring I/O 2023 - YouTube
Spring I/O 2023 - Barcelona, 18-19 MayGitHub repo: https://github.com/EXXETA/springio-2023GraalVM is mainly known for its native image-compiler. But it provi...
Published   July 12, 2023
🌐
Stack Overflow
stackoverflow.com › questions › 79694148 › how-to-run-a-python-script-from-a-java-spring-boot-application-in-eclipse-ide
How to run a Python script from a Java Spring Boot application in Eclipse IDE? - Stack Overflow
I'm working with a Java Spring Boot application in Eclipse IDE and want to call a Python script from my backend service to process image files (such as removing backgrounds). The Python script works fine when run independently using python3 script.py input.png output.svg.