Trouble with running java using Popen
norseman at hughes.net
Wed Jun 24 00:11:17 CEST 2009
Edward Grefenstette wrote:
> I have a java prog I need to run at some point during the execution of
> a python module.
> The path to the folder containing the all the relevant java stuff
> (which runs fine from the command line) is stored in pkgpath. The
> relevant code is this:
>>>> arglist = "java -Xmx1024m SemanticVectorsEvaluator ." + indexpath
>>>> SemVectPackage = Popen(arglist, stdout=PIPE, shell=True)
> Here indexpath is the path to a particular index file (usually
> indexpath = "./indexfolder/fileindex"), so that effectively Popen
> should be running the equivalent of the shell command:
> java -Xmx1024m SemanticVectorsEvaluator ../indexfolder/fileindex
> which, again, runs fine in the terminal.
> However running the program returns the following error (echoed from
> shell, doesn't interrupt prog):
> Exception in thread "main" java.lang.NoClassDefFoundError:
> I have no idea why this isn't working. Anyone have any suggestions as
> to how I might troubleshoot this?
First glance shows you using ./ in code and ../in terminal. Might check
Second glance shows you using Popen vs popen (OK) but is that the
correct stdout? It is the CHILD's stdout that is being requested here.
(Probably what you had in mind, but ... is it?)
Third item - running from the terminal usually loads the terminal
environment. Running under program control may NOT load the environment.
This is a particular problem in Window$. Is the difference going to
effect your efforts?
As for Java specific problems (if any) I don't know. Another might.
More information about the Python-list