Windows paths, Java, and command-line arguments, oh my!

Daniel Dittmar daniel at dittmar.net
Mon Sep 19 18:18:28 EDT 2005


Steve M wrote:
> I'm trying to invoke a Java command-line program from my Python program
> on Windows XP. I cannot get the paths in one of the arguments to work
> right.
> 
> The instructions for the program describe the following for the
> command-line arguments:
> 
> java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFIG_DIRECTORY
> 
> They also give an example:
> 
> java -Dsalesforce.config.dir=c:\config -jar sforcedataloader.jar
> 
> If I type the example above at the cmd.exe command line the thing works
> (assuming I have the config file in c:\config). What doesn't work is
> these two lines:
> 
> cmd = r'java -jar sforcedataloader.jar -Dc:\config'
> os.system(cmd)

If you write
java -jar x.jar -Dwhatever=x
then -Dwhatever=x is passed as an argument to the main method of the 
main class in x.jar.

If you write
java -Dwhatever=x -jar x.jar
then -Dwhatever=x is interpreted by java and put into the system properties.

Daniel



More information about the Python-list mailing list