# java2python_cn **Repository Path**: xucs007/java2python_cn ## Basic Information - **Project Name**: java2python_cn - **Description**: Originally forked from github java2python, it seems 4-5 years has no updates, its current (early 2020) doesn't work with Python3, doesn't work with Antlr 4, doesn't work with Chinese comments (on Ubuntu 2018.04). So I forked it, at least made it work with Chinese, Antlr3, Python2.7 - **Primary Language**: Python - **License**: LGPL-2.1 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2020-01-07 - **Last Updated**: 2024-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Fork Comments: Forked from https://github.com/natural/java2python, during 2020 January, add Chinese-comments support. 2020/1月从Github上的java2python分支过来,加入了对Java代码中的中文说明的处理. 原始代码最近几年似乎已没有什么更新。不再支持Antlr4, Python3. 现在的版本, 只解决了中文处理 (Python2 + Antlr3). ## 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: ```bash $ cat HelloWorld.java ``` ```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: ```bash $ j2py HelloWorld.java ``` ```python #!/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) ``` [downloads]: https://github.com/natural/java2python/downloads [installation]: https://github.com/natural/java2python/tree/master/doc/install.md [introduction]: https://github.com/natural/java2python/tree/master/doc/intro.md [lots of docs]: https://github.com/natural/java2python/tree/master/doc/ [many options]: https://github.com/natural/java2python/tree/master/doc/customization.md [plenty of tests]: https://github.com/natural/java2python/tree/master/doc/tests.md