java - How to run a python file that's inside a jar? -
public class bar { public static void main (string[] args) { string pythonpath = this.getclass().getresource("data/__hello__.py").getpath(); string command = new stringbuilder() .append("python ").append(pythonpath) .append(" -v ").append("201309") .tostring(); cmdlineutil.runfromcommandline(command); } } when run bar without jar file, works fine. command end executing
python ~/projectdirectory/com/__hello.py -v 201309
however, when create jar file project : test.jar
$jar tf test.jar com/__hello__.py com/bar.java and try execute it:
java -classpath test.jar com.bar
i error
error - "python: can't open file 'file: ~/projectdirectory/test.jar!/com/__hello__.py': [errno 2] no such file or directory\n" anyone know how can fix problem? have unzip file jar , make command point unzipped file? i'd avoid doing if possible.
Comments
Post a Comment