Jython on Ubuntu

Installation

Option 1: Synaptic

  • install jython package

Option 2

java -jar jython_installer-2.5.1.jar

Using the terminal

  • check jython is in your PATH
  • test it's working:
#! /usr/bin/env jython
 
from java.util import Date, Locale
 
print "hi"
print Date();
jython test.py

Import jars

Option 1: environment variable JYTHONPATH

export JYTHONPATH=/home/toto/lib1.jar:/home/toto/lib2.jar

Option 2: add to sys.path directly in the script

  l = [
    "/home/toto/lib1.jar",
    "/home/toto/lib2.jar"
  ]
  for s in l:
    sys.path.append(s)

Source: http://sujitpal.blogspot.com/2006/10/using-jython-to-call-java.html

Using Pydev in Eclipse

  • Window -> Preferences -> Pydev -> Interpreter - Jython -> button “New...” -> select jython.jar from your jython installation.
  • Run: Run As -> Jython Run

Import jars

  • right-click on your project folder -> properties -> PyDev - PYTHONPATH -> Add zip/jar/egg

Feedback

Thanks!!

Apr 16, 2011
#1
Thank you.
asd
Jun 11, 2012
#2