4 |
import org.python.util.PythonInterpreter; |
import org.python.util.PythonInterpreter; |
5 |
import org.python.core.*; |
import org.python.core.*; |
6 |
|
|
7 |
|
/** A wrapper class for starting Gzz.py from Java. This class can be used |
8 |
|
* as the main class in gzz.jar |
9 |
|
*/ |
10 |
|
|
11 |
public class Main { |
public class Main { |
12 |
public static void main(String[] args) throws PyException { |
public static void main(String[] args) throws PyException { |
13 |
String[] pyargs = new String[args.length+1]; |
String[] pyargs = new String[args.length+1]; |
14 |
System.arraycopy(args, 0, pyargs, 1, args.length); |
System.arraycopy(args, 0, pyargs, 1, args.length); |
15 |
pyargs[0] = "Gzz.py"; |
pyargs[0] = "Gzz.py"; // sys.argv[0] is the command name |
16 |
|
// Python search path will be the same as Java classpath |
17 |
System.setProperty("python.path", |
System.setProperty("python.path", |
18 |
System.getProperty("java.class.path")); |
System.getProperty("java.class.path")); |
19 |
PythonInterpreter.initialize(System.getProperties(), null, pyargs); |
PythonInterpreter.initialize(System.getProperties(), null, pyargs); |