| <!doctype html> |
| <html> |
| <head> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE- 2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <link href="/theme/css/lucene/global.css?v=0e493d7a" rel="stylesheet" type="text/css"> |
| |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> |
| <meta name="Distribution" content="Global"/> |
| <meta name="Robots" content="index,follow"/> |
| |
| <script type="text/javascript" src="/theme/javascript/lucene/prototype.js?v=0e493d7a"></script> |
| <script type="text/javascript" src="/theme/javascript/lucene/effects.js?v=0e493d7a"></script> |
| <script type="text/javascript" src="/theme/javascript/lucene/slides.js?v=0e493d7a"></script> |
| <script src="https://www.apachecon.com/event-images/snippet.js"></script> <title>Apache Lucene - Install JCC</title> |
| <meta name="keywords" |
| content="apache, apache lucene, apache solr, solr, lucene |
| search, information retrieval, spell checking, faceting, inverted index, |
| open source"/> <meta property="og:type" content="website" /> |
| <meta property="og:url" content="https://lucene.apache.org/pylucene/jcc/install.html"/> |
| <meta property="og:title" content="Install JCC"/> |
| <meta property="og:description" content="Getting JCC's Source Code JCC's source code is included with PyLucene's. If you've downloaded the PyLucene source code already, JCC's..."/> |
| <meta property="og:image" content="https://lucene.apache.org/theme/images/lucene/lucene_og_image.png?v=0e493d7a"/> |
| <meta property="og:image:secure_url" content="https://lucene.apache.org/theme/images/lucene/lucene_og_image.png?v=0e493d7a"/> |
| <link rel="shortcut icon" type="image/png" |
| href="/theme/images/lucene/lucene-favicon.png?v=0e493d7a"/><link href="/theme/css/lucene/pylucene.css?v=0e493d7a" rel="stylesheet" type="text/css"> |
| </head> |
| <body id="home"> |
| <div id="wrap"> |
| <div id="header"> |
| <div id="logo" style="float:left"> |
| <a href="/"> |
| <img border="0" src="/theme/images/lucene/lucene_logo_green_300.png?v=0e493d7a" alt="Lucene Logo"/> |
| </a> |
| </div> |
| <!-- TODO: Search disabled as it does not work, 2021-02-21 |
| <div id="search" style="float:right;zoom:1"> |
| <form id="quick-search" method="GET" action="https://sematext.com/opensee/lucene" name="searchform"> |
| <fieldset> |
| <input type="search" id="q" name="q" placeholder="Search with Apache Solr..." class="class1 class2 hint" accesskey="q"> |
| </fieldset> |
| </form> |
| </div>--> |
| <div id="nav"> |
| <ul> |
| <li><a href="/pylucene/jcc/index.html">JCC</a></li> |
| <li><a href="/pylucene/mailing-lists.html">Mailing Lists</a></li> |
| <li><a href="https://issues.apache.org/jira/browse/PYLUCENE">Issue Tracker</a></li> |
| <li><a href="/pylucene/index.html">PyLucene</a></li> |
| <li><a class="last" href="/">Lucene</a></li> |
| </ul> |
| </div> |
| |
| </div> <!-- End #header --> |
| |
| <div id="content-wrap" class="clearfix"> |
| <div id="main"> |
| <div> |
| <h1 class="title">Install JCC</h1> |
| <h2 id="getting-jccs-source-code">Getting JCC's Source Code</h2> |
| <p>JCC's source code is included with PyLucene's. If you've downloaded the PyLucene |
| source code already, JCC's is to be found in the <em>jcc</em> subdirectory.</p> |
| <p>To get the JCC source code only from SVN use:</p> |
| <div class="highlight"><pre><span></span><code><span class="err">svn co https://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc jcc</span> |
| </code></pre></div> |
| |
| <h2 id="building-jcc">Building JCC</h2> |
| <p>JCC is a Python extension written in Python and C++. It requires a Java Runtime |
| Environment to operate as it uses Java's reflection APIs to do its work. It is |
| built and installed via <em>distutils</em> or <a href="https://pypi.python.org/pypi/setuptools">setuptools</a>.</p> |
| <ul> |
| <li> |
| <p>On MacOS and Windows, <em>setup.py</em> will attempt to find a JDK on your system and |
| report what it found by showing the values for <em>JAVAHOME</em> and <em>JAVAFRAMEWORKS</em> it |
| was able to derive. If the JDK installation that was found is not the one you |
| wish to use or if you are not on MacOS or Windows, you can either edit <em>setup.py</em> |
| and review that the values in the <em>INCLUDES</em>, <em>CFLAGS</em>, <em>DEBUG_CFLAGS</em>, <em>LFLAGS</em>, |
| <em>JAVAC</em>, and <em>JAVADOC</em> dicts are correct for your system or set <strong>all</strong> of the |
| environment variables <em>JCC_JDK</em>, <em>JCC_INCLUDES</em>, <em>JCC_CFLAGS</em>, <em>JCC_DEBUG_CFLAGS</em>, |
| <em>JCC_LFLAGS</em>, <em>JCC_JAVAC</em> and <em>JCC_JAVADOC</em>, using os.pathsep as value separator |
| to override them. The values hereby configured are going to be compiled into JCC's |
| <em>config.py</em> file and are going to be used by JCC when invoking <em>setuptools</em> to |
| compile the extensions it is used to generate code for.</p> |
| </li> |
| <li> |
| <p>At the command line, enter:</p> |
| </li> |
| </ul> |
| <div class="highlight"><pre><span></span><code><span class="err">python setup.py build</span> |
| <span class="err">sudo python setup.py install</span> |
| </code></pre></div> |
| |
| <h2 id="requirements">Requirements</h2> |
| <p>JCC requires a Java Development Kit to be present. It uses the Java Native Invocation (JNI) interface and expects <em><jni.h></em> and the Java libraries to be present at build and runtime.</p> |
| <p>JCC requires a C++ compiler. A recent C++ compiler for your platform is recommeded and should work as expected.</p> |
| <h2 id="shared-mode-support-for-the-shared-flag">Shared Mode: Support for the <em>--shared</em> Flag</h2> |
| <p>JCC includes a small runtime that keeps track of the Java VM and of Java objects |
| escaping it. Because there can be only one Java VM embedded in a given process |
| at a time, the JCC runtime must be compiled as a shared library when more than |
| one JCC-built Python extension is going to be imported into a given Python process.</p> |
| <p>Shared mode depends on <em>setuptools</em>' capability of building plain shared libraries |
| (as opposed to shared libraries for Python extensions).</p> |
| <p>Currently, shared mode is supported with <em>setuptools 0.6c7</em> and above out of the |
| box on MacOS and Windows. On Linux, a patch to <em>setuptools</em> needs to be applied |
| first. This patch is included in the JCC source distribution in the <em>jcc2/patches</em> |
| directory, <em>patch.43</em>. This patch was submitted to the <em>setuptools</em> project |
| years ago via "Issue 43", originally tracked in the long defunct |
| bugs.python.org/setuptools bug tracker. <em>setup.py</em> will attempt to apply the |
| patch for you via monkeypatching.</p> |
| <p>The <em>shared mode disabled</em> error reported during the build of JCC's on Linux |
| contains the exact instructions on how to patch the <em>setuptools</em> installation |
| with <em>patch.43</em> on your system.</p> |
| <p>Shared mode is also required when embedding Python in a Java VM as JCC's runtime |
| shared library is used by the JVM to load JCC and bootstrap the Python VM via the |
| JNI.</p> |
| <p>When shared mode is not enabled, not supported or <em>distutils</em> is used instead |
| of <em>setuptools</em>, static mode is used instead. The JCC runtime code is statically |
| linked with each JCC-built Python extension and only one such extension can be |
| used in a given Python process at a time.</p> |
| <p>As setuptools grows its shared library building capability it is expected that] |
| more operating systems should be supported with shared mode in the future.</p> |
| <p>Shared mode can be forced off by building JCC with the <em>NO_SHARED</em> environment' |
| variable set.</p> |
| <p>There are two defaults to consider here:</p> |
| <ul> |
| <li> |
| <p>Is JCC built with shared mode support or not ?</p> |
| <ul> |
| <li> |
| <p>By default, on MacOS, Linux or Windows, this is the case when using a modern |
| version of <em>setuptools</em></p> |
| </li> |
| <li> |
| <p>On other operating systems shared mode support is off by default - not |
| supported - because shared mode depends on <em>setuptools</em>'s capability of |
| building a regular shared library which is still an experimental feature.</p> |
| </li> |
| </ul> |
| </li> |
| <li> |
| <p>Is a JCC-built Python extension built with shared mode ?<br/>By default, no, |
| shared mode is enabled only with the <em>--shared</em> command line argument.</p> |
| </li> |
| </ul> |
| <h2 id="notes-for-macos">Notes for MacOS</h2> |
| <p>On MacOS, Java is installed by Apple's setup as a framework. The values in |
| <em>setup.py</em> for <em>INCLUDES</em> and <em>LFLAGS</em> for <em>darwin</em> should be correct and ready |
| to use when <em>setup.py</em> was able to derive <em>JAVAHOME</em> and <em>JAVAFRAMEWORKS</em>.</p> |
| <p>However, if you intend to use the 'system' Python from a Java VM on MacOS -- |
| Python embedded in Java -- you will need to add the flags <em>"-framework", "Python"</em> |
| to the <em>LFLAGS</em> value.</p> |
| <h2 id="notes-for-linux">Notes for Linux</h2> |
| <p>JCC has been built and tested on a variety of Linux distributions, 32- and 64-bit. |
| Getting the java configuration correct is important and is done differently for |
| every distribution.<br/>For example:</p> |
| <ul> |
| <li>On Debian 11, the commands below install Temurin Java 17, Python 3.9, gcc, g++ and make</li> |
| </ul> |
| <p>install Temurin Java (Adoptium)</p> |
| <div class="highlight"><pre><span></span><code><span class="err">sudo -s</span> |
| <span class="err">apt install wget apt-transport-https gnupg</span> |
| <span class="err">wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add -</span> |
| <span class="err">echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list</span> |
| <span class="err">apt update</span> |
| <span class="err">apt install temurin-17-jdk</span> |
| </code></pre></div> |
| |
| <p>install gcc, g++ and make</p> |
| <div class="highlight"><pre><span></span><code><span class="err">sudo apt install gcc-x86-64-linux-gnu g++-x86-64-linux-gnu make</span> |
| </code></pre></div> |
| |
| <p>install Python 3.9 with development, virtual environment and setuptools support</p> |
| <div class="highlight"><pre><span></span><code><span class="err">sudo apt install python3.9-dev python3-venv python3-setuptools</span> |
| </code></pre></div> |
| |
| <p>The samples flags for Linux in JCC's setup.py should be close to correct. |
| See earlier section about <a href="#shared">Shared Mode</a> for Linux support.</p> |
| <h2 id="notes-for-solaris-11-with-sun-studio-c-12">Notes for Solaris 11 with Sun Studio C++ 12</h2> |
| <p>JCC has been built and tested on Solaris 11 with Sun Studio C++ 12, Java 1.6 and |
| Python 2.4.</p> |
| <p>Because JCC is written in C++, Python's <em>distutils</em> must be nudged a bit to |
| invoke the correct compiler. Sun Studio's C compiler is called <em>cc</em> while its C++ |
| compiler is called <em>CC</em>. To build JCC, use the following shell command to ensure |
| that the C++ compiler is used:</p> |
| <p><code>$ CC=CC python setup.py build</code></p> |
| <p>Shared mode is not currently implemented for Solaris, <em>setuptools</em> needs to be |
| taught how to build plain shared libraries on Solaris first.</p> |
| <h2 id="notes-for-solaris-111-with-gcc-45">Notes for Solaris 11.1 with GCC 4.5</h2> |
| <p>JCC has been built and tested on Solaris 11.1 with gcc 4.5, Java 1.7 and Python |
| 2.6. Make sure, you?ve already installed the following packages: gcc-4.5, jre-1.7, |
| jdk-1.7, python-2.6, ant, gnu-make and subversion.</p> |
| <p>Missing packages can be installed via <em>pkg install</em>.</p> |
| <ul> |
| <li>Edit setup.py and do the following changes: Inside JDK = { ? } change the entry |
| for sunos5 to: <code>'sunos5': '/usr/jdk/instances/jdk1.7.0',</code> Inside CFLAGS= {?} change |
| the entry for sunos5 to: <code>'sunos5': ['-fno-strict-aliasing', '-Wno-write-strings'],</code></li> |
| <li><code>python setup.py build</code></li> |
| <li><code>su python setup.py install</code></li> |
| </ul> |
| <h2 id="notes-for-windows">Notes for Windows</h2> |
| <p>At this time, JCC has been built and tested on Win2k and WinXP with a variety of |
| Python and Java versions.</p> |
| <ul> |
| <li>Adding the Python directory to <em>PATH</em> is recommended.</li> |
| <li>Adding the Java directories containing the necessary DLLs and to <em>PATH</em> is a must.</li> |
| <li>Adding the directory containing <em>javac.exe</em> to <em>PATH</em> is required for shared |
| mode (enabled by default if <em>setuptools >= 0.6c7</em> is found to be installed).</li> |
| </ul> |
| <h2 id="notes-for-python-23">Notes for Python 2.3</h2> |
| <p>To use JCC with Python 2.3, setuptools is required</p> |
| <ul> |
| <li>download <a href="https://pypi.python.org/pypi/setuptools">setuptools</a>.</li> |
| <li>edit the downloaded <em>setuptools</em> egg file to use python2.3 instead of python2.4.</li> |
| <li>At the command line, run:<br/> <code>$ sudo sh setuptools-0.6c7-py2.4.egg</code></li> |
| </ul> |
| </div> |
| </div> |
| <div id="sidebar"> |
| <h1 id="documentation">Documentation<a class="headerlink" href="#documentation" title="Permanent link">¶</a></h1> |
| <ul> |
| <li><a href="https://www.apache.org/licenses/">License</a></li> |
| <li><a href="/pylucene/jcc/features.html">Features</a></li> |
| <li><a href="/pylucene/jcc/install.html">Install</a></li> |
| </ul> |
| |
| <h1 id="events">Events<a class="headerlink" href="#events" title="Permanent link">¶</a></h1> |
| <ul> |
| <a class="acevent" data-format="square" data-mode="light" data-width="160" data-style="border: 1px solid lightgrey"></a> |
| </ul> |
| |
| <h1 id="asf-links">ASF links<a class="headerlink" href="#asf-links" title="Permanent link">¶</a></h1> |
| <ul> |
| <li><a href="https://www.apache.org">Apache Software Foundation</a></li> |
| <li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li><a href="https://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li> |
| <li><a href="https://www.apache.org/security/">Security</a></li> |
| </ul> |
| |
| <h1 id="related-projects">Related Projects<a class="headerlink" href="#related-projects" title="Permanent link">¶</a></h1> |
| <ul> |
| <li><a href="http://hadoop.apache.org">Apache Hadoop</a></li> |
| <li><a href="http://manifoldcf.apache.org/">Apache ManifoldCF</a></li> |
| <li><a href="http://lucenenet.apache.org/">Apache Lucene.Net</a></li> |
| <li><a href="http://mahout.apache.org">Apache Mahout</a></li> |
| <li><a href="http://nutch.apache.org">Apache Nutch</a></li> |
| <li><a href="http://opennlp.apache.org/">Apache OpenNLP</a></li> |
| <li><a href="http://tika.apache.org">Apache Tika</a></li> |
| <li><a href="http://zookeeper.apache.org">Apache Zookeeper</a></li> |
| </ul> </div> |
| </div> <!-- End #content-wrap --> |
| |
| <div id="footer"> |
| <div class="copyright"> |
| <p> |
| Copyright © 2011-2024 The Apache Software Foundation, Licensed under |
| the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>. <a href="/privacy.html">Privacy Policy</a> <br/> |
| Apache and the Apache feather logo are trademarks of The Apache Software Foundation. Apache Lucene, Apache Solr and their |
| respective logos are trademarks of the Apache Software Foundation. Please see the <a href="https://www.apache.org/foundation/marks/">Apache Trademark Policy</a> |
| for more information. |
| </p> |
| </div> |
| </div> </div> <!-- End #wrap --> |
| </body> |
| </html> |