Man Linux: Main Page and Category List

NAME

       jythonc - compile Python source to real Java classes

SYNOPSIS

       jythonc  [ -p, --package package ] [ -j, --jar jarfile ] [ -d, --deep ]
       [ -c, --core ] [ -a, --all ] [ -b, --bean jarfile ] [ -A, --addpackages
       pkgs  ]  [  -w,  --workdir  directory  ]  [  -s, --skip modules ] [ -C,
       --compiler path ] [ -J, --compileropts options  ]  [  -f,  --falsenames
       names ] module ...

       jythonc --help

DESCRIPTION

       JythonC  is  a  utility  that  compiles Python source code to real Java
       classes, and is used for building applets, servlets, beans and  so  on,
       as well as allowing for Python classes to be subclassed in Java.

       JythonC  generates  actual  Java  source  code, and then invokes a Java
       compiler over this source code to create the .class  files.   Thus  you
       will  need  access to a Java compiler.  The jythonc script will attempt
       to guess the specifics of the installed  compiler;  see  jython.conf(5)
       for details on specifying these yourself.

       In  order to create a real Java class, 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.

   Compiling Python Methods
       Normally, compiled Python methods are not directly callable from  Java.
       There   is  simply  not  sufficient  information  in  a  Python  method
       definition to create a useable Java method.  There are however two ways
       a  Python  method can be made into real Java method.  Both ways require
       that the Python class have a Java class or a Java interface as its base
       class.

       Overriding / Implementing a Java method:
              By  overriding  a Java method, the overridden method’s signature
              is used for the real Java class.   That  includes  return  type,
              privacy  modifier, arguments, argument types and throws clauses.

       Adding a Java method signature to a Python method docstring:
              Using a special convention in the method  docstring  allows  for
              the creation of a corresponding Java method.  The signature must
              be written on one line and must start with the text  @sig.   All
              class  names  (except  those  in java.lang) must be specified as
              fully qualified class names.  An example is:

                     def setExpression(self, e):
                             "@sig public void  setExpression(java.lang.String
                             e)"

OPTIONS

       A summary of options is included below.

       -p, --package package
              Put all compiled code into the given Java package.

       -j, --jar jarfile
              Specifies  a  jar  archive  to create and put the results of the
              compilation into.  Implies --deep.

       -d, --deep
              Compile all Python dependencies of the module.  This  is  useful
              for creating applets.

       -c, --core
              Include  the  core  Jython  libraries  (about 130K).  Needed for
              applets since some browsers don’t yet support multiple archives.
              Implies --deep.

       -a, --all
              Include all of the Jython libraries (core, compiler and parser).
              Implies --deep.

       -b, --bean jarfile
              Compile into  the  given  jar  archive,  including  the  correct
              manifest for the Java bean.

       -A, --addpackages pkgs
              Include  Java  dependencies  from  the  given  list of packages.
              Default is org.python.modules and org.apache.oro.text.regex.

       -w, --workdir directory
              Specifies the working directory into which  the  generated  code
              will be placed.  Default is ./jpywork.

       -s, --skip modules
              Don’t  include  any  of  the given modules in compilation.  This
              should be a comma-separated list of modules.

       -C, --compiler path
              Use the specified Java compiler to turn generated  Java  sources
              into  class files.  If this is set to NONE then compilation ends
              with  the  generation  of  the   Java   source   file(s).    See
              jython.conf(5)   for  alternate  ways  of  specifying  the  Java
              compiler.

       -J, --compileropts options
              Options  to  pass  directly   to   the   Java   compiler.    See
              jython.conf(5)  for  alternate  ways of specifying Java compiler
              options.

       -f, --falsenames names
              A comma-separated list of names that are always false.   Can  be
              used to short-circuit if clauses.

       module ...
              A  list  of  Python modules to compile.  These can be either .py
              files or module names on the python path (see jython.conf(5) for
              further details on property python.path).

       --help Print a usage message and exit.

ENVIRONMENT VARIABLES

       JAVA (default: /usr/bin/java)
              The Java interpreter to use when running Jython and JythonC.

       JAVA_OPTIONS (default: empty)
              Options  to pass to the Java interpreter when running Jython and
              JythonC.

       JAVAC (default: /usr/bin/javac)
              The Java compiler to use when running JythonC.

EXAMPLES

       To create the file appletdemo.jar containing all of the applet demos in
       the current directory as well as the core Jython libraries:

              example$ jythonc --core --deep --jar appletdemo.jar *.py

       Note:  One  special thing to consider when building applets is that the
       Java VM version used when compiling the sources  must  usually  be  the
       same  as  the  VM  version used by the browser.  If a newer JVM is used
       when compiling the applets, the compiled code may  have  references  to
       classes that do not exist in older JVMs.

       To  generate  a  skeleton class to allow a Python class to be used as a
       java.awt.Component in a Java gui program:

              example$ jythonc Graph.py

       To generate a Jython-based bean:

              example$       jythonc       --deep        --bean        f2c.jar
              conversion.FahrenheitToCelsius

SEE ALSO

       jython(1), jython.conf(5).

       If  the Debian package jython-doc is installed, full documentation from
       the  Jython  authors  will  be  available   in   /usr/share/doc/jython-
       doc/html/.

AUTHOR

       This  manual  page  was prepared by Ben Burton <bab@debian.org> for the
       Debian GNU/Linux system (but may be used by others).  It is based  upon
       the official Jython documentation.

                                 July 7, 2001