Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 5819d3d4b1b79753897a93be1bcc5f25 > files > 12

jython-manual-2.2.1-5.7.fc15.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- THIS PAGE IS AUTOMATICALLY GENERATED.  DO NOT EDIT. -->
<!-- Wed Feb  9 15:17:20 2011 -->
<!-- USING HT2HTML 2.0 -->
<!-- SEE http://ht2html.sf.net -->
<!-- User-specified headers:
Title: Invoking the Jython Interpreter

-->

<head>
<title>Invoking the Jython Interpreter</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="generator" content="HT2HTML/2.0">
<style type="text/css">
body { margin: 0px; }
</style>
</head>
<body bgcolor="#ffffff" text="#000000"
      marginwidth="0" marginheight="0"
      link="#0000bb"  vlink="#00000"
      alink="#ff0000">
<!-- start of page table -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!-- start of banner row -->
<tr>
<!-- start of corner cells -->
<td width="150" valign="middle" bgcolor="#cccccc" class="corner">

<center>
    <a href="http://www.jython.org/">
    <img border="0" src="./images/jpython-new-small.gif"></a></center> </td>
<td width="15" bgcolor="#cccccc">&nbsp;&nbsp;</td><!--spacer-->
<!-- end of corner cells -->
<!-- start of banner -->
<td width="90%" bgcolor="#cccccc" class="banner">
<!-- start of site links table -->
<table width="100%" border="0"
cellspacing="0" cellpadding="2"
       bgcolor="#ffffff">
<tr>
    <td bgcolor="#cccccc">
<a href="http://www.jython.org/">Home</a>
    </td>
    <td bgcolor="#cccccc">
<a href="http://www.python.org/">www.python.org</a>
    </td>
</tr><tr>
    <td bgcolor="#cccccc">
<a href="http://www.jython.org/download.html">Download</a>
    </td>
    <td bgcolor="#cccccc">
<a href="./index.html">Documentation</a>
    </td>
</tr>
</table><!-- end of site links table -->

</td><!-- end of banner -->
</tr><!-- end of banner row -->
<tr><!-- start of sidebar/body row -->
<!-- start of sidebar cells -->
<td width="150" valign="top" bgcolor="#cccccc" class="sidebar">
<!-- start of sidebar table -->
<table width="100%" border="0" cellspacing="0" cellpadding="3"
       bgcolor="#ffffff">
<tr><td bgcolor="#666699"><b><font color="#ffffff">
Documentation
</font></b></td></tr>
<tr><td bgcolor="#cccccc">
<a href="./index.html">Overview</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="whatis.html">Executive Summary</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="interpreter.html">Invoking Jython</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="registry.html">Jython Registry</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="embedding.html">Embedding</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="compile.html">Compiling Jython from source</a>
</td></tr>
<tr><td bgcolor="#cccccc">&nbsp;
<tr><td bgcolor="#666699"><b><font color="#ffffff">
Working with Java
</font></b></td></tr>
<tr><td bgcolor="#cccccc">
<a href="usejava.html">The Basics</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="properties.html">JavaBean Properties</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="jarray.html">Java arrays</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="subclassing.html">Subclassing</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="jythonc.html">Building applets, servlets, beans...</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="jreload.html">Reloading java classes</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="zxjdbc.html">zxJDBC</a>
</td></tr>
<tr><td bgcolor="#cccccc">&nbsp;
<tr><td bgcolor="#666699"><b><font color="#ffffff">
Python Docs (exits)
</font></b></td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://www.python.org/doc/tut/tut.html">Python Tutorial</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://www.python.org/doc/lib/lib.html">Library Reference</a>
</td></tr>
<tr><td bgcolor="#cccccc">&nbsp;
<tr><td bgcolor="#666699"><b><font color="#ffffff">
Other
</font></b></td></tr>
<tr><td bgcolor="#cccccc">
<a href="differences.html">Jython vs. CPython</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">Jython FAQ (exit)</a>
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://www.geocrawler.com/archives/3/7017/2000/">List Archives</a> (exit)
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://www.python.org/workshops/1997-10/proceedings/hugunin.html">JPython paper</a> (exit)
</td></tr>
<tr><td bgcolor="#cccccc">&nbsp;
<tr><td bgcolor="#666699"><b><font color="#ffffff">
Contact
</font></b></td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a>
</td></tr>
<tr><td bgcolor="#cccccc">
&nbsp;
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://www.python.org/">
<center>
    <img border="0" src="./images/PythonPoweredSmall.gif"></center>
</a>
</td></tr>
<tr><td bgcolor="#cccccc">
&nbsp;
</td></tr>
<tr><td bgcolor="#cccccc">
<a href="http://sourceforge.net/">
<center>
 <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center>
</a>
</td></tr>
</table><!-- end of sidebar table -->

</td>
<td width="15">&nbsp;&nbsp;</td><!--spacer-->
<!-- end of sidebar cell -->
<!-- start of body cell -->
<td valign="top" width="90%" class="body"><br>
<h3>Invoking the Jython Interpreter</h3>

<P>Jython can be invoked from the shell using the following command:</P>

<pre>
jython [options] [-jar jar | -c cmd | file | -] [args]
</pre>

Options and arguments:

<p><table border="1">
<tr><td><b>-i</b></td>
    <td>inspect interactively after running script, and force prompts, 
    even if stdin does not appear to be a terminal
</tr><tr>
    <td><b>-S</b></td>
    <td>don't imply <em>import site</em> on initialization
</tr><tr>
    <td><b>-D<em>prop</em>=<em>value</em></b></td>
    <td>Set the jython property <em>prop</em> to <em>value</em></td>
</tr><tr>
    <td><b>-jar <em>jar</em></b></td>
    <td>program to run is read from the <tt>__run__.py</tt> file in
    the specified <em>jar</em> file
</tr><tr>
    <td><b>-c <em>cmd</em></b></td>
    <td>program to run is passed in as the <em>cmd</em> string.  This
    option terminates the options list
</tr><tr>
    <td><b><em>file</em></b></td>
    <td>run <em>file</em> as the program script
</tr><tr>
    <td><b>-</b></td>
    <td>program is read from standard-in (default; interactive mode is 
    used if on a tty).  This flag allows you to pipe a file into
    Jython and have it be treated correctly.  This would be useful
    in a case like: <tt>filter&nbsp;file&nbsp;|&nbsp;jython&nbsp;-</tt>
</tr><tr>
    <td><b>--help</b></td>
    <td>print a usage message and exit
</tr><tr>
    <td><b>--version</b></td>
    <td>print Jython version number and exit
</tr><tr>
    <td><b><em>args</em></b></td>
    <td>arguments passed to the program in <tt>sys.argv[1:]</tt>
</tr>
</table>

<H3>Details</H3>

<P><tt>jython</tt> is a short script that invokes your local JVM,
sets the Java property <tt>install.path</tt> to an appropriate value,
and then runs the Java classfile
<tt>org.python.util.jython</tt>.</P>

<H3>Making Jython Scripts Executable</H3>

<P>To make a jython &quot;.py&quot; file executable on a Unix system
you can add the following line to the top of the file:

<PRE><B>#! /usr/bin/env jython</B></PRE>

<P>For this magic to work, you must have <tt>jython</tt> somewhere on your
standard PATH.  You also must also make the &quot;.py&quot; file
executable.  Typically this is done with the command:
<TT>chmod +x foo.py</TT>.

<p><I>Note: &quot;#! &lt;...&gt;/jython&quot; will probably not work to
make your script executable.  This is because &quot;jython&quot; is
itself a script, and the #! magic requires that the file to execute is
a binary executable on most Unix variants.  Using
&quot;/usr/bin/env&quot; will get around this problem - and make your
scripts more portable in the bargain.</I>

</td><!-- end of body cell -->
</tr><!-- end of sidebar/body row -->
</table><!-- end of page table -->
</body></html>