calling a java app from python
Delaney, Timothy
tdelaney at avaya.com
Mon Jul 1 03:01:13 EDT 2002
> From: Anoop P B [mailto:anoop79 at myrealbox.com]
>
> is there no way of doing this cross-platform?
>
> Can someone please throw some light on possible solutions to this
> problem. My ultimate aim is only to run the java program through my
> python script. However, I cannot use os.system() since my
> python program
> gets blocked which is not acceptable. I need my python script to call
> the java program and continue executing.
>
> note: the java class is in the same directory in which my
> python script lies
http://www.jython.org/
// TestJava.java
public class TestJava
{
public static final void main (String[] args )
{
System.out.println("TestClass.main()");
for (int i = 0; i < args.length; i++)
{
try
{
Thread.currentThread().sleep(0);
}
catch (InterruptedException ix )
{
}
System.out.println(" " + args[i]);
}
}
}
# TestPy.py
import threading
import time
import TestJava
t = threading.Thread(None, TestJava.main, None, (['1', '2', '3',],))
t.start()
print 'TestPy'
for c in 'abcdef':
time.sleep(0)
print ' %s' % (c,)
t.join()
Tim Delaney
More information about the Python-list
mailing list