📄 245.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Developer's Handbook -> Downloading and Installing JPython</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyN.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="8.html" class="navtitle">Web Development</a> > <a href="0672319942.html" class="navtitle">Python Developer's Handbook</a> > <a href="241.html" class="navtitle">18. JPython</a> > <span class="nonavtitle">Downloading and Installing JPython</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="244.html" title="Java Integration"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0672319942&snode=245" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="245.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="246.html" title="The Interpreter"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="6%2F1%2F2002+6%3A24%3A33+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039196038240039088173205162105045222218068074150171193064206</font><a href="read5.asp?bookname=0672319942&snode=245&now=6%2F1%2F2002+6%3A24%3A33+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>
Downloading and Installing JPython</h3>
<p>Next, you find the required steps that you need to perform in order to download and install JPython. Visit the following address, and download the latest version.</p>
<P>
<A TArget="_blank" HREF="http://www.jpython.org/download.html">http://www.jpython.org/download.html</a>
</p>
<p>You have two choices for downloading JPython. You can either download the JPython version that contains the <a NAME="idx1073750631"></a>
<a name="idx1073750632"></a>OROMatcher regular expression library, or the other version that doesn't contain it. Note that it's required that you decide between the two versions. Only if you decide to use the version that comes with the OROMatcher, will you have access to the <tt class="monofont">re</tt> module. However, you will have to agree with a different kind of licensing.</p>
<p>Before spending time downloading the file, verify whether you have a working Java 1.1 or 1.2 compatible JVM installed. In case you don't have one, you will need to locate one on the Internet and install the right JVM for your system.</p>
<p>JPython is distributed as a self-extracting <Tt cLass="monofont">.class</Tt> file created by <tt cLass="monofont">InstallShield - Java Edition.</TT> To install JPython, you need to open the command line to the directory in which you have placed the <TT clasS="monofont">JPython11.class</TT> file. Note that if you have downloaded the <Tt claSS="monofont">JPythonONLY11.class</TT> file, you must first rename it to <tt clASS="monofont">JPython11.class.</Tt>
</p>
<pre>
ren JPythonONLY11.class JPython11.class
</pre>
<p>Then, type the following command to start the installation process.</p>
<pre>
<java interpreter> JPython11
</pre>
<p>Depending on your system, you have to type one of the following options. Note that you don't have to include the <tt cLasS="monofont">.class</tt> on the end of the filename.</p>
<Pre>
java JPython11
jre JPython11
jview JPython11
</prE>
<p>In case you don't have a GUI, you need to add the following argument to the previous command: <tt CLASs="monofont">-o dir_to_install_to.</tt> JPython will install to the specified directory without activating the graphical installer.</p>
<P>After initiating the installation process, you will be prompted to accept the terms of the license (see <A HRef="245#1.html">Figure 18.1</a>). Read it and say yes to continue with the process.</p>
<CENTer>
<h5>
<a NAME="1"></a>Figure 18.1. When you accept the terms of the license, JPython is installed on your system.</h5>
<img border="0" width="500" heigHt="381" sRc="graphics/18fig01.gif" alT="graphics/18fig01.gif">
</centEr>
<p>Remember to check the Installation Notes after completing the installation.</p>
<P>Now, you should be able to run JPython by typing the following command:</P>
<PRe>
jpython
</pre>
<P>If you are using a Windows system, you can have access to JPython by double-clicking on its icon.</P>
<H4>
Downloading the CPython Library</H4>
<p>As of now, JPython comes with support for only a small set of the standard Python modules. For those who will concentrate on development using Java packages, the modules provided by JPython should be fine, but note that CPython has a wide variety of useful modules.</p>
<p>If you already have CPython 1.5.1, 1.5.2, or a later version installed on your computer, you can use its library. If you don't have CPython installed, you can get its libraries from the JPython Web site. For example, the libraries for version 1.5.2 are stored in the following file:</p>
<P>
<A TArget="_blank" HREF="http://www.jpython.org/pylib152e.jar">http://www.jpython.org/pylib152e.jar</a>
<a name="idx1073750633"></a>
<a name="idx1073750634"></a>
<a name="idx1073750635"></a>
<a NamE="idx1073750636"></a>
<a nAme="idx1073750637"></a>
<a Name="idx1073750638"></A>
<A NAme="idx1073750639"></a>
</p>
<P>To install the standard Python libraries, use the following command:</P>
<PRe>
jpython -jar pylib152e.jar
</pre>
<P>Besides the regular distribution download page, the latest snapshots of the JPython source code are always available via CVS too.<A NAme="idx1073750640"></a>
<a NAME="idx1073750641"></a>
<a name="idx1073750642"></a>
</p>
<h4>
Licensing</h4>
<p>Starting with version 1.1 beta 1, JPython has two separate distributions. This is because JPython uses a third-party library for handling regular expressions梩he standard <tt class="monofont">re</tt> module is implemented using <A naMe="idx1073750643"></a>
<a Name="idx1073750644"></a>
<Tt clASS="monofont">OROMatcher,</Tt> which is a regular expression library by <tt cLASS="monofont">ORO, Inc.</tt>
</p>
<p>Because <TT CLass="monofont">OROMatcher</tT> has a different kind of license, the JPython distribution that uses it requires a specific license as well because <TT Class="monofont">OROMatcher</tt> is not completely free software. (It doesn't allow you to have access to its source code.)</p>
<p>Currently, at the ORO Web site, you can find a note saying that the company plans to open source their software, releasing it under the Apache license, so the restrictions on using <tt class="monofont">OROMatcher</tt> might be lifted. You should keep an eye on that.</p>
<p>However, JPython provides another distribution that comes without the library, which makes the regular expression capability not available. This distribution is a completely open source version of JPython. Note that if later you decide to use <tT clAss="monofont">OROMatcher,</tT> you can accept its licensing agreement, and integrate it with the free distribution of JPython that you already have. Check out the OROMatcher site at</p>
<p>
<a tArgeT="_blank" HREf="http://www.savarese.org/oro/">http://www.savarese.org/oro/</a>
<a nAME="idx1073750645"></A>
<a namE="idx1073750646"></A>
<A Name="idx1073750647"></a>
<A NAMe="idx1073750648"></a>
<a name="idx1073750649"></a>
</p>
<h4>
JVMs That Support JPython</h4>
<p>As of now, JPython should run successfully on any bug-free fully 1.1 or 1.2 compliant Java Virtual Machine (JVM). Next, you have a list of Operating System specific JVMs. Even if your platform is not listed here, it doesn't mean that it doesn't have a JVM.</p>
<h5>
Linux</h5>
<p>JDK 1.1.x and 1.2.x from blackdown.org桰t is suggested that you use either the 1.1.7 JVM or 1.2 JVM.</p>
<p>
<a tArgEt="_blank" hrEf="http://www.blackdown.org/java-linux.html">http://www.blackdown.org/java-linux.html</a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -