Frage

I am working on an implementation of ESA, I changed one of the java files, compiled it using the command

javac -cp lib/*:esalib.jar ./src/clldsystem/esa/ESAAnalyzer.java

and pasted the .class file to the corresponding directory(esalib.jar/clldsystem/esa) in the .jar file. Also i changed the name the original corresponding .class file.

Next, i have a python script which uses a command

java -cp lib/*:esalib.jar clldsystem.esa.ESAAnalyzer param1 param2

but on running the python script, the command runs fine when used as:

x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer computer apple'
args=shlex.split(x)
p=subprocess.Popen(args)
p.wait()

But gives an Error: Could not find or load main class when used as:

x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer word1 word2'
args=x.split()
p=subprocess.Popen(args)
p.wait()

in the same script. I am reading the variables word1 and word2 from a file. Why would it work fine at one place and give an error at other? I have checked using print statements that i am reading from the file correctly, so that must not be an issue. Thanks

here are the details of what happened:

nishant@nishant-Inspiron-1545:~/esalib$ python test.py
['java', '-cp', 'lib/*:esalib.jar', 'clldsystem.esa.ESAAnalyzer', 'bottle', 'apple']
index loaded to memory
bottl
appl
vector 1 dimensions: 1782
vector 2 dimensions: 2766
0.024397644631615697
beach
['people', 'sand', 'desert', 'snow']
['java', '-cp', '"lib/*:esalib.jar"', 'clldsystem.esa.ESAAnalyzer', 'word1', 'word2']
Error: Could not find or load main class clldsystem.esa.ESAAnalyzer
beach 
people
['java', '-cp', '"lib/*:esalib.jar"', 'clldsystem.esa.ESAAnalyzer', 'word1', 'word2']
Error: Could not find or load main class clldsystem.esa.ESAAnalyzer
beach
sand

and so on for every iteration

War es hilfreich?

Lösung

this works:

x='java -cp "lib/*:esalib.jar" clldsystem.esa.ESAAnalyzer %s %s' % (word1, word2)
args=shlex.split(x)
print args
p=subprocess.Popen(args)
p.wait()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top