Run Trainable Weka Segmentation with no user interface

Hi everyone! I am new to Image J, and am having difficulty programming a script with no user interface. Specifically, I want to change the code “Example: apply classifier to all images in folder” found here Scripting the Trainable Weka Segmentation - ImageJ, so instead of manually picking the input and output directories, it will use ones predefined in the code. How do you code this in beanshell/java?