CINXE.COM
Home | Jython
<!DOCTYPE html> <html lang="en-US"> <head> <meta charset='utf-8'> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,maximum-scale=2"> <link rel="stylesheet" type="text/css" media="screen" href="assets/css/style.css?"> <link rel="icon" type="image/png" href="assets/favicon32.png"> <!-- Begin Jekyll SEO tag v2.8.0 --> <title>Home | Jython</title> <meta name="generator" content="Jekyll v3.10.0" /> <meta property="og:title" content="Home" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="The Python runtime on the JVM" /> <meta property="og:description" content="The Python runtime on the JVM" /> <link rel="canonical" href="https://www.jython.org/" /> <meta property="og:url" content="https://www.jython.org/" /> <meta property="og:site_name" content="Jython" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="Home" /> <script type="application/ld+json"> {"@context":"https://schema.org","@type":"WebSite","description":"The Python runtime on the JVM","headline":"Home","name":"Jython","url":"https://www.jython.org/"}</script> <!-- End Jekyll SEO tag --> </head> <body> <!-- HEADER --> <div id="header_wrap" class="outer"> <header class="inner"> <a id="forkme_banner" href="https://github.com/jython/jython">View on Github</a> <a id=logo href="index"><img id="logo" src="assets/jython.png" alt="Jython Logo" height="70" width="109"></a> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"> <div class="navbar"> <a href="index">Home</a> <a href="news">News</a> <a href="download">Download</a> <div class="dropdown"> <button class="dropbtn">Documentation <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="installation">Installation</a> <a href="https://www.javadoc.io/doc/org.python/jython-standalone/2.7.2">JavaDoc</a> <a href="https://apidia.net/java/Jython">APIdia (alternative to JavaDoc)</a> <a href="https://docs.python.org/2.7/">Python 2.7</a> <a href="https://jython.readthedocs.io/en/latest/">Jython Book</a> <a href="https://wiki.python.org/jython/">Wiki</a> <a href="archived_sites">Archived Sites</a> </div> </div> <div class="dropdown"> <button class="dropbtn">Development <i class="fa fa-caret-down"></i> </button> <div class="dropdown-content"> <a href="https://github.com/jython/jython/issues/">Bug tracker</a> <a href="https://github.com/jython/jython/">Github</a> <a href="legacy-dev">Legacy</a> <a href="https://sourceforge.net/p/jython/mailman/">Mailing List</a> <a href="https://jython-devguide.readthedocs.io/en/latest/">Developer Guide</a> <a href="jython-3-mvp">Jython 3 Features (MVP)</a> <a href="jython-3-roadmap">Jython 3 Roadmap</a> <a href="https://apidia.net/java/Jython/3">Jython 3 (snapshot) on APIdia</a> <a href="https://github.com/jython/jython.github.io/">Website source</a> </div> </div> <a href="links">Links</a> </div> <style type="text/css"> /* Navbar container */ .navbar { overflow: hidden; } /* Links inside the navbar */ .navbar a { float: left; font-size: 16px; color: white; padding: 13px 16px 15px 16px; text-decoration: none; } /* The dropdown container */ .dropdown { float: left; overflow: hidden; } /* Dropdown button */ .dropdown .dropbtn { font-size: 16px; border: none; outline: none; color: white; padding: 14px 16px; background-color: inherit; font-family: 'Myriad Pro', Calibri, Helvetica, Arial; line-height: 1.5; -webkit-font-smoothing: antialiased; } .dropdown .dropbtn .fa { padding-left: 3px; } /* Add a blue background color to navbar links on hover */ .navbar a:hover, .dropdown:hover .dropbtn { background-color: #0090ff; } /* Dropdown content (hidden by default) */ .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } /* Links inside the dropdown */ .dropdown-content a { float: none; color: black; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } /* Add a grey background color to dropdown links on hover */ .dropdown-content a:hover { background-color: #ddd; } /* Show the dropdown menu on hover */ .dropdown:hover .dropdown-content { display: block; } </style> </header> </div> <!-- MAIN CONTENT --> <div id="main_content_wrap" class="outer"> <section id="main_content" class="inner"> <h2 id="what-is-jython">What is Jython?</h2> <p>The Jython project provides implementations of <a href="https://www.python.org/">Python</a> in <a href="https://go.java/index.html">Java</a>, providing to Python the benefits of running on the JVM and access to classes written in Java. The current release (a Jython 2.7.x) only supports Python 2 (sorry). There is work towards a Python 3 in the project鈥檚 GitHub repository.</p> <p>Jython implementations are freely available for both commercial and non-commercial use. They are distributed with source code under the <a href="https://github.com/jython/jython/blob/master/LICENSE.txt">PSF License v2</a>.</p> <p>Jython is complementary to Java and is especially suited for the following tasks:</p> <ul> <li>Embedded scripting - Java programmers can add the Jython libraries to their system to allow end users to write simple or complicated scripts that add functionality to the application.</li> <li>Interactive experimentation - Jython provides an interactive interpreter that can be used to interact with Java packages or with running Java applications. This allows programmers to experiment and debug any Java system using Jython.</li> <li>Rapid application development - Python programs are typically 2-10x shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python and Java allows developers to freely mix the two languages both during development and in shipping products.</li> </ul> <h5 id="here-is-an-example-of-running-python-code-inside-a-simple-java-application">Here is an example of running Python code inside a simple Java application</h5> <div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span> <span class="kd">public</span> <span class="kd">class</span> <span class="nc">JythonHelloWorld</span> <span class="o">{</span> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="nc">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> <span class="k">try</span><span class="o">(</span><span class="nc">PythonInterpreter</span> <span class="n">pyInterp</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">PythonInterpreter</span><span class="o">())</span> <span class="o">{</span> <span class="n">pyInterp</span><span class="o">.</span><span class="na">exec</span><span class="o">(</span><span class="s">"print('Hello Python World!')"</span><span class="o">);</span> <span class="o">}</span> <span class="o">}</span> <span class="o">}</span> </code></pre></div></div> <h5 id="here-is-an-example-of-using-java-from-python-code">Here is an example of using Java from Python code</h5> <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">java.lang</span> <span class="kn">import</span> <span class="n">System</span> <span class="c1"># Java import </span> <span class="k">print</span><span class="p">(</span><span class="s">'Running on Java version: '</span> <span class="o">+</span> <span class="n">System</span><span class="p">.</span><span class="n">getProperty</span><span class="p">(</span><span class="s">'java.version'</span><span class="p">))</span> <span class="k">print</span><span class="p">(</span><span class="s">'Unix time from Java: '</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">System</span><span class="p">.</span><span class="n">currentTimeMillis</span><span class="p">()))</span> </code></pre></div></div> <h2 id="getting-started">Getting Started</h2> <p>Ready to get started? Head over to <a href="download">Downloads</a>.</p> <p>Or you could read a quick overview of <a href="jyspecific">features specific to Jython</a>.</p> <p>A more detailed introduction and reference can be found in the <a href="https://jython.readthedocs.io/en/latest/">Jython Book</a>.</p> <h2 id="who-uses-jython">Who uses Jython?</h2> <p>Jython is embedded in lots of projects. See some from <a href="https://mvnrepository.com/artifact/org.python/jython-standalone/usages">MVNRepository</a></p> <ul> <li><a href="https://www.ibm.com/developerworks/websphere/library/techarticles/1004_gibson/1004_gibson.html">IBM Websphere</a> - Use Jython to provide administrative scripting capabilities.</li> <li><a href="https://pig.apache.org/">Apache PIG</a> - Use Jython to support user defined functions.</li> <li><a href="http://imagej.net">ImageJ</a> - Use Jython to provide scripted image processing.</li> <li><a href="http://www.opengda.org/">GDA</a> - Use Jython to script scientific experiments.</li> <li><a href="http://robotframework.org/">Robot Framework</a> - A generic test automation framework for acceptance testing and acceptance test-driven development (ATDD) which runs on Jython.</li> <li><a href="https://www.tigerjython.ch/en">TigerJython</a> - An educational programming environment that is based on Jython.</li> <li><a href="https://jythonmusic.me/">JEM/JythonMusic</a> - An environment for music making and creative programming using Jython.</li> </ul> </section> </div> <!-- FOOTER --> <div id="footer_wrap" class="outer"> <footer class="inner"> <p>Jython is a member of the <a href="https://www.python.org/psf/">Python Software Foundation</a></p> <p>Published with <a href="https://pages.github.com">GitHub Pages</a></p> </footer> </div> </body> </html>