Saturday, July 3, 2010

OO Hello World - Jython

Let’s have a look at the hello world program in Jython which is the Java implementation of the Python programming language for the JVM runtime.

The code is identical to the previous post of IronPython. This is because at the end, both are written in the Python programming language. Nevertheless, I decided to create separate posts for those developers looking for their preferred platform and also because of the “Jython Info” section, which of course differs between the two implementations. In the future, if I post about IronPython or Jython I will be using their respective libraries and frameworks, so it makes sense to differentiate.

By the way, you can see my previous post here:
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.

class Greet(object):   
 name = ''  
 def __init__(self, name): = name.capitalize()  
 def salute(self):  
  print 'Hello', name, '!'  
# Greet the world!  
g = Greet('world')  

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
import java

class Greet(object): 
 name = ''
 def __init__(self, name): = name.capitalize()
 def salute(self):
  print 'Hello',, '!'

# Greet the world!
def main():
 g = Greet('world')

The Program Output:

Jython Info:
“Jython is an implementation of the Python programming language which is designed to run on the Java(tm) Platform. It consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM, a set of support libraries which are used by the compiled Java bytecodes, and extra support to make it trivial to use Java packages from within JPython. JPython has been renamed and superseded by Jython.” Taken from: (

Current Version:
Developed by:
Jim Hugunin > Barry Warsaw > Samuele Pedroni > Brian Zimmer > Frank Wierzbicki, Ted Leung
Jim Hugunin
Influenced by:
Python (Guido van Rossum)
Predecessor Language
Predecessor Appeared
Predecessor Creator
Runtime Target:
Latest Framework Target:
Mono Target:
Allows Unmanaged Code:
Yes (using native Python/C libraries)
Source Code Extension:
Case Sensitive:
Free Version Available:
Open Source:
Latest IDE Support:
NetBeans 6.9
IntelliJ IDEA
Language Reference:
Extra Info:

1 comment:

  1. We are ERPTREE Leading oracle fusion HCM Online Training institute. We are providing online training services since 1999. still we are adding more oracle related courses as the technology changes. 2000+ online courses are available. we all ways achieve our goal in satisfying students in result we
    have global recognition to our site. we have best faculty for all of our online courses.

    Oracle fusion HCM Online Training

    Oracle Fusion HCM Training