title: How do I automate jprofiler to save snapshots of multiple target java programs with different arguments
body: <p>I wanted to profile my java program where I was opening a file and performing read and write operations over it . The file to be read is a large XML file, and i wanted to compare memory stats/snapshots for parsing the file using techniques like batching / stream-reading / standard xml parsing etc.</p>
  <p>So let's say we had three programs that I wanted to save the snapshots for :</p>
  <p>BatchParsing.java</p>
  <pre><code>public class BatchParsing {
  
    public static void main(String[] args) throws Exception {
        File = new File(&quot;path/to/file&quot;)
        // parse XML using batch logic
    }
  }
  </code></pre>
  <p>StreamReading.java</p>
  <pre><code>public class StreamReadingParsing {
  
    public static void main(String[] args) throws Exception {
        File = new File(&quot;path/to/file&quot;)
        // parse XML using stream reader
    }
  }
  </code></pre>
  <p>NormalParsing.java</p>
  <pre><code>public class NormalParsing {
  
    public static void main(String[] args) throws Exception {
        File = new File(&quot;path/to/file&quot;)
        // parse XML by loading whole file
    }
  }
  </code></pre>
  <p>Moreover , I wanted to analyse not one , but  multiple files of different sizes, and instead of running a loop over different files, I wanted to check profiling results by running each of the above mentioned programs separately for each file.</p>
  <p>In then end , I wanted to save my profiling snapshots as follows.</p>
  <pre><code>- snapshot_results
     - batch_results
        - small_file.jps
        - average_file.jps
        - large_file.jps
     - stream_results
        - small_file.jps
        - average_file.jps
        - large_file.jps
     - normal_parsing_results
        - small_file.jps
        - average_file.jps
        - large_file.jps
  </code></pre>
  <p>I could do the above using the GUI, but wanted to automate all of this . I am currently using jprofiler over intelliJ on macOS .</p>