Python calling Java

Alan Kennedy alanmk at hotmail.com
Tue Feb 19 06:28:59 EST 2002


Jim,

The 5-6 second delay you are experiencing is very likely caused by the
initialisation overhead of whatever JVM you are using.

You would see the same overhead if you avoided Jython altogether, and
wrote your "Hello World" CGI in pure Java (It's probably worth doing
this, just to prove that Jython is not the culprit here).

If you're going to do CGI with Java and/or Jython, you're going to
have to live with this JVM initialisation overhead: it's unavoidable,
unless you compile your Java/Jython into native code using a Java to
native code compiler (which is really going too far to solve such a
simple problem).

Is there any way that you can install a servlet engine on your
machine? If so, that's the way to go. This is the whole purpose for
Java servlets: to avoid the very JVM initialisation overhead you are
currently experiencing.

Java is just not a CGI language, and hence any language derived from
it, e.g. Jython, Jacl, will be equally unusable for CGI scripting.

Regards,

Alan.

"jimh" <jim at jim.jim> wrote in message news:<a4rjq4$4n8$1 at web1.cup.hp.com>...
> We have a bunch of Python (cgi) scripts producing html behind an Apache web
> server.  We also have a set of Java libraries that I want to access from
> these Python scripts, but I haven't been able to figure out how to do this.
> I have downloaded and tried out Jython, but it takes 5-6 seconds just to run
> a one-line 'print "hi"' script, and this is, of course, not acceptable for a
> web server.



More information about the Python-list mailing list