In order to build a real java class from a Python class, you will use the freeze tool. This can be found in Tools/freeze/freeze.py. You can invoke this tool on a Python file using the following:
jpython freeze.py [-jar jarfile] [-cab cabfile] [-dir directory] [-main]
[-core] [-shallow] [module]*
-jar jarfile | Specifies a .jar file to create and put the results of the freeze into.
Not really useful for "shallow" freezes |
-cab cabfile | Specifies a .cab file to create and put the files into.
This only works with Microsoft's JVM (.cab is a MS format) |
-dir directory | Specifies that the files should be put into the given directory.
If none of the first three options are specified, -dir '.' is assumed |
-main | Will be used to specify that a Java main method should be created.
This is not yet implemented. |
-core | Include the core JPython libraries (about 130K)
Needed for applets since Netscape doesn't yet support multiple archives |
-shallow | Only create a proxy wrapper for this class
This is probably your best bet for everything except creating applets |
module* | A list of Python modules to freeze
Can be either modules names that are on the python.path or .py files |
The Python module must contain a Python class with the same name as the module, and that Python class must subclass exactly one Java class or interface. The real Java class created will be a subclass of whatever Java class is subclassed.
c:\jpython> jpython Tools\freeze\freeze.py -core -jar appletdemo.jar Demo\applet\*.pyTo generate a skeleton class to allow a Python class to be used as java.awt.Component in a Java gui program, I used the following command:
c:\jpython> jpython Tools\freeze\freeze.py -shallow Demo\javaclasses\Graph.py