I'm working on a project base on java. And the java program will run command to call a python script.
The python script is used tabula-py to read a pdf file and return the data.
I tried the python script was work when I direct call it in terminal (pytho3 xxx.py)
However, when I tried to call the python script from java, it will throw error:
Error from tabula-java:Error: File does not exist
Command '['java', '-Dfile.encoding=UTF8', '-jar', '/home/ubuntu/.local/lib/python3.8/site-packages/tabula/tabula-1.0.5-jar-with-dependencies.jar', '--pages', 'all', '--lattice', '--guess', '--format', 'JSON', '/home/ubuntu/Documents/xxxx.pdf']' returned non-zero exit status 1.
I tried to call the script in full path, provide the pdf file in full path, tried sys.append(python script path)
and both of them are not worked.
I've tried to call the tabula in java command, i.e. java -Dfile.encoding=UTF8 -jar /home/ubuntu/.local/lib/python3.8/site-packages/tabula/tabula-1.0.5-jar-with-dependencies.jar "file_path"
And it's work and can read the file. However back to java to call the python script is not work
Is there any method to solve this? Use the tabula in java program is not an option for my case