This is a requirement for self-built projects. Previously, Jython was used to call Python scripts in Java. However, after a third-party class library introduced by python, Jython does not contain such packages, the result is that the import fontforge cannot be used and is not defined.
The following describes how to use a Java function and the runtime class to call a Python script. JavaProgram
Import Java. io. ioexception; public class testjava {public static void main (string [] ARGs) throws ioexception {// use the ping command // process EE = runtime.getruntime(cmd.exe C (// "cmd.exe/C start Ping 10.5.2.19");/* try {runtime RT = runtime. getruntime (); // system. out. println ("start! "); Process proc = runtime.getruntime(cmd.exe C (" Export Python C :\\ python32 \ Program \ OUTFILE. PY "); Proc. waitfor (); // waiting the completion of the command // system. out. println ("end");} catch (exception e) {e. printstacktrace ();} * // OK this is a usable try {runtime RT = runtime. getruntime (); system. out. println ("START"); process proc = runtime.getruntime(.exe C ("Python OUTFILE. PY "); Proc. waitfor (); system. out. println ("end");} catch (exception e) {e. printstacktrace () ;}// main}
The preceding requirements require that OUTFILE. py be in the root directory of the Java project.
It is not complete yet. It is to be continued. It is now in windows. Later, We will test the use of Ubuntu and how to call the calculation results.