package st.extreme.jython; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.net.URL; import org.python.core.PySystemState; import org.python.util.PythonInterpreter; public class LibImportTest { private static final String FILE_NAME = "test_lib_import.py"; public static void main(String[] args) { PySystemState.initialize(); PythonInterpreter interp = new PythonInterpreter(); FileInputStream fis = getFileInputStream(); if (fis != null) { interp.execfile(fis); } else { System.out.println("unable to read ".concat(FILE_NAME)); } } private static FileInputStream getFileInputStream() { FileInputStream fis = null; URL url = LibImportTest.class.getResource(FILE_NAME); if (url != null) { String file = url.getPath(); try { fis = new FileInputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); } } return fis; } }