This library uses the Translator class from retranslator library.
Installing: pip install py2java
import:
from py2java import PythonToJava
Usage:
sourceText = """
sourceText = "test"
def main():
print(sourceText)
class lol(object):
\"\"\"docstring for lol\"\"\"
_LOL = "test" # test variable
"""
translator = PythonToJava(useRegex=1)
print(translator.compile(sourceText))
using java controller:
jc = PythonToJava(useRegex=1, javaVersion=8) # standart javaVersion is 10