# HG changeset patch
# User Paul Boddie You can run Java classes by finding one with a main method and executing
it. Here's a comparison of a freshly prepared Java class being run in Python
-and in a Java virtual machine:
cd tests/
@@ -141,7 +141,7 @@ transforming it, optimising it, and so on. (Instead, there's been more emphasis on lots of runtime baggage for things which could be done by analysis of the code with modified bytecode being produced as a result, - and let's not get started on some of the syntactical enhancements.) + and let's not get started on some of the syntax enhancements!) Consequently, stability might be an issue for some configurations, especially since CPython doesn't fail particularly graciously with badly behaved bytecode. @@ -192,6 +192,22 @@ several places on the PYTHONPATH, and this is something that generally isn't allowed/supported with the classic Python module import mechanisms. +java.lang.String
and seemingly
+ java.lang.StringBuffer
required just for the usage of
+ strings, and with the classic main
method having
+ String[]
in its signature, some kind of library
+ implementation is obviously necessary. Whilst importing everything from
+ the .jar files bundled with Sun's JRE might be tempting, there may be a
+ certain amount of native calling going on in secret which would defeat
+ this approach, and anyone seriously interested in running Java code in
+ Python should really want to steer clear of such proprietary dependencies
+ anyway. It could be possible to wrap and make use of GNU Classpath or
+ some other open source Java API implementation, but the cleanest (but not
+ necessarily the least time-consuming) approach is surely to implement the
+ standard API classes in Python, and a package called java
is
+ included which contains some fairly quick and dirty implementations to
+ get things working.