Python
  Home arrow Python arrow Page 2 - Introduction to Jython
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PYTHON

Introduction to Jython
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 21
    2005-02-22


    Table of Contents:
  • Introduction to Jython
  • Installing Jython
  • Calling Java Classes
  • Embedding

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Introduction to Jython - Installing Jython
    ( Page 2 of 4 )

    Jython may be obtained from the Jython website:

    http://www.jython.org

    Currectly, the latest version is Jython 2.1. Download it and then move to the directory where it is installed. Next, open the file with your Java interpreter. For example:

    java jython-21

    The installation program will be presented to you, and installing it from there should be pretty straightforward. If you're using Jython 2.1 in conjunction with Java 1.4 or later, be sure to include the source in your installation. Move to the directory where you installed Jython and open up "org/python/core/Py.java" in your favorite text editor. Replace every appearance of "assert" with "a_ssert" and ever appearance of "enum" with "e_num". Do the same with "org/python/compiler/CodeCompiler.java" and "org/python/parser/PythonGrammar.java". Note that the latter will require you to replace "e_numeration" to "Enumeration" when you are done. Jython 2.1 uses the two terms, which were set as keywords in Java 1.4.

    Once you're done, move to the directory where you installed Jython and start up the Jython interactive interpreter:

    jython

    If everything has gone correctly, you should see something that looks a lot like the Python interactive interpreter. Let's test it out by executing some Python code:

    >>> print 'Hello World!'
    Hello World!
    >>> import math
    >>> print math.sqrt ( 25 )
    5.0
    >>> someList = [ 5, 3, 4, 2 ]
    >>> print someList [ 0 ]
    5
    >>> print math
    (module 'math' (built-in))

    As you can see, things work exactly the same as they do in Python.



     
     
    >>> More Python Articles          >>> More By Peyton McCullough
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek