title: python: run java command using variables in the command
body: <p>I have a large python script and parses data and then preps it for import to another system. I want to trigger the import to the other system from this script as well.</p>
  
  <p>the bash script to import looks something like this</p>
  
  <pre><code>export DPATH="/home/user/"
  export DCONF="/home/user/conf"
  java -cp "$DPATH/*" -D.config.dir=$DCONF com.sa.uploader.process.ProcessRunner process.name=upsert
  </code></pre>
  
  <p>In my python script I want to do something like this:</p>
  
  <pre><code>dpath = "/home/user/"
  dconf = "/home/user/conf"
  drun  = " -cp "+str(dpath)+" -D.config.dir="+str(dconf)+" com.sa.uploader.process.ProcessRunner process.name=upsert"
  </code></pre>
  
  <p>that way I can simply run this:</p>
  
  <pre><code>java = subprocess.call(['java', drun])
  </code></pre>
  
  <p>Obviously, the drun portion of the last line there isn;t recognized as a valid thing to run. The error is</p>
  
  <pre><code>Error: Could not find or load main class  -cp .home.user.....etc
  </code></pre>
  
  <p>I then test this:</p>
  
  <pre><code>java = subprocess.call(['java', '-version'])
  </code></pre>
  
  <p>Which does work. So i then tried:</p>
  
  <pre><code>jtest = " -version"
  
  java = subprocess.call(['java', jtest])
  </code></pre>
  
  <p>and of course. </p>
  
  <pre><code>Error: Could not find or load main class  -version
  </code></pre>
  
  <p>I'm sure theres a way to do this. 
  The reason is because the java command will be the same every time, but the paths can change. Ill eventually make the path varabiales args to they can be inputs. For now I just want it to work statically. </p>