Best way to generate java with python?

What is the best way to generate java from python?

I want to write a decorator that generates java code to call a json version of a function (I can use existing decorators to export json-api).

What is the best way to generate java, should I consider things like FSM?

Ideally, I can write my code once for the server and generate code for interacting with it for different languages ​​(Java first).

Edit (pulled out a deleted answer from a comment):
The java code will be running on Android, and the python code will be on the django server ... In addition, I want to be able to statically generate Java code and use this as part of an API that people can use.

+5
source share
3 answers

You can always create Java code in the same way that webapps create HTML: with a template. Then you can get the java source code compiled into bytecode using a regular Java compiler (see the javax.tools Package )

Not necessarily the best option, but definitely an option (and a pretty simple btw)

+1
source

Reuse is good. Complexity is the price.

This will make you pay twice or more later. Measure your ROI (return on investment) before taking the jump.

[Edit:]

  • You can use Jython, which will make writing glue code easier as a call to Java functions.
  • jythonc Python Java, Java, .class,
  • , . - cheetah. .
0

My advice? Generate JavaScript code instead of Java code. Android can execute JavaScript code using WebView .

-1
source

All Articles