I have a jar file that launches a python script. It works if my jar file is at the root of the working directory. If I move it out of the working directory, it cannot find the python script anymore. Why does my call to find the script file not look inside the jar? I use ./(the path). Why does it automatically look in the working directory? I thought it would be self-contained.
1 Answer
Reposting my guess as an answer:
Are you looking for the python script as a file? or as a resource? You might want to share more information about your problem because right now all anyone can do is guess. My guess is that you're trying to read the Python script as a file, and files don't exist inside of jars. To solve this, either read the Python script as a file outside of Java, or look for it as a resource inside of the jar. If the latter, I'm not sure if you can run the script or not.
For more, please see this link: stackoverflow: can-i-make-a-jar-execute-a-python-script
Another clever option: stackoverflow: how-do-you-invoke-a-python-script-inside-a-jar-file-using-python
file? or as aresource? You might want to share more information about your problem because right now all anyone can do is guess. My guess is that you're trying to read the Python script as a file, and files don't exist inside of jars.