0

I have created a Java application that executes a Python script using a runtime. I was wondering if there is a way to include the python.exe with the necessary libraries with the Jar file?

  • 1
    Since you're talking about the `exe` file, I suppose you're using Windows. Java was meant to be portable to different operating systems, and your application definitely won't be portable. If you need to execute a Python script at runtime, I'd advice you not to invent anything from scratch and just use the Jython project: https://www.jython.org – Forketyfork Mar 02 '19 at 20:36
  • Thanks for the response. The problem I've got is that I need to use python 3 which, as far as I'm aware, Jython doesn't support – Crackers42 Mar 02 '19 at 22:15

1 Answers1

0

You should check whether it is the best option to bundle the windows specific python executable into your .jar file or if you want to use something like jython to execute python script from java.

But to answer your question this mainly depends on how you build your .jar file. Are you using a build system like gradle/maven/ant or do you use an IDE to build it?

Here are some links for you on how to generally bundle assets/resources into a .jar.

Build systems

  1. Gradle
  2. Maven
  3. Ant

IDEs

  1. IntelliJ
  2. Netbeans
  3. Eclipse
FlorianDe
  • 1,202
  • 7
  • 20
  • Thanks for the response. The problem I have is I need python 3 for the libraries I'm using with, as far as I'm aware, jython doesn't support – Crackers42 Mar 02 '19 at 22:13