title: Creating a New JMeter Test Purely in Java for Java Sampler
body: <p>I've created a JMeter Java request and copied the jar to ext directory (<code>apache-jmeter-3.1\lib\ext</code>).
  I'm trying to run the test on a remote machine. From the GUI I'm able to configure and run the Java request.
  Also able to invoke the test via Java code using the JMX file as below.</p>
  
  <pre><code>ClientJMeterEngine jmeter = new ClientJMeterEngine("myclient");
  File file = new File(RemoteJmeterTest.class.getResource("/finalSample.jmx").getFile());
  JMeterUtils.loadJMeterProperties("D:/apache-jmeter-3.1/bin/jmeter.properties");
  JMeterUtils.setJMeterHome("D:/Tools/apache-jmeter-3.1");
  
  HashTree testPlanTree = SaveService.loadTree(file); 
  jmeter.configure(testPlanTree); 
  jmeter.runTest(); 
  </code></pre>
  
  <p>Now I want to creating a New JMeter Test Purely in Java. But I don't know how to configure the Java sampler.
  I see example <a href="https://www.blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui" rel="nofollow noreferrer">here</a> pointing how to configure the HTTP Sampler.
  Instead of HTTPSampler, I need to configure my Java Request.
  Please assist.</p>