Skip to content
Simple but effective library to translate Java source code to Python.
Branch: master
Clone or download
Latest commit b803756 May 10, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Bump to version 0.5.1. May 3, 2012
doc Erroneous link May 10, 2016
java2python change sync helper to be py26 friendly Oct 23, 2014
test
.gitignore
license.txt First pass at setup.py and install.md. Feb 5, 2012
readme.md Adds test suite docs. Apr 24, 2012
setup.py add mod.include to setup.py Oct 10, 2014

readme.md

java2python

Simple but effective tool to translate Java source code into Python.

The java2python package can translate any syntactically valid Java source code file. The generated Python code is not guaranteed to run, nor is guaranteed to be syntactically valid Python. However, java2python works well many cases, and in some of those, it creates perfectly usable and workable Python code.

For more information, read the introduction. To install, refer to the installation page.

There are lots of docs, plenty of tests, and many options for controlling code generation.

If you're looking for old releases, check the downloads link above.

Here's a very simple example:

$ cat HelloWorld.java
// This is the HelloWorld class with a single method.
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world.");
    }
}

Next we run our program:

$ j2py HelloWorld.java
#!/usr/bin/env python
""" generated source for module HelloWorld """

#  This is the HelloWorld class with a single method.
class HelloWorld(object):
    """ generated source for class HelloWorld """

    @classmethod
    def main(cls, args):
        """ generated source for method main """
        print "Hello, world."

if __name__ == '__main__':
    import sys
    HelloWorld.main(sys.argv)
You can’t perform that action at this time.