title: Pass arguments to Python script to jar/Java
body: <p>I have a Python script that uses variables such as an email address and a message.
  I need to pass that data from the Python script to the Java jar.</p>
  <p>I can run the jar from Python with:</p>
  <pre class="lang-python prettyprint-override"><code>import subprocess
  subprocess.call(['java', '-jar', 'JavaEmail.jar'])
  </code></pre>
  <p>I need to pass variables such as email_address and a file.txt to the following Java program:</p>
  <pre class="lang-java prettyprint-override"><code>import java.util.Properties;
  import javax.mail.Message;
  import javax.mail.MessagingException;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  
  
  public class JavaEmail{
  
      public static void main(String args[]) {
          String to = &quot;receive@abc.om&quot;;            // sender email
          String from = &quot;sender@abc.com&quot;;       // receiver email
          String host = &quot;127.0.0.1&quot;;                   // mail server host
  
         Properties properties = System.getProperties();
          properties.setProperty(&quot;mail.smtp.host&quot;, host);
  
          Session session = Session.getDefaultInstance(properties); 
          // default session
          System.out.println(to);
          try {
              MimeMessage message = new MimeMessage(session);        
              // email message
  
              message.setFrom(new InternetAddress(from)); 
              // setting header fields
             
              message.addRecipient(Message.RecipientType.TO, 
                                 new InternetAddress(to));
              message.setSubject(&quot;Test Mail from Java Program&quot;); // subject line
  
              // actual mail body
              message.setText(&quot;&quot;);
  
              // Send message
              Transport.send(message);
              System.out.println(&quot;Email Sent successfully....&quot;);
          } catch (MessagingException mex) {
              mex.printStackTrace();
          }
      }
  }
  </code></pre>