I haven't been able to get it working with User Defined Java Class step but using the Javascript step instead. You need to copy the JAR to pentaho /lib or /libext folder first. Then in the modified javascript step I just called the class. Here is my step XML
<entry>
<name>JavaScript</name>
<description />
<type>EVAL</type>
<script>
var filename=parent_job.getVariable("filename","");
var filenameClean=filename+"_clean";
package.CsvCleaner(filename,filenameClean);
</script>
<parallel>N</parallel>
<draw>Y</draw>
<nr>0</nr>
<xloc>800</xloc>
<yloc>1008</yloc>
</entry>
The important part is package.CsvCleaner(filename,filenameClean);
actually invokes the constructor of the class with the two parameters and I have added my code in the constructor. You can also call methods and stuff.
I guess the User Defined Java is called in a similar way -add the jar to /lib import the class and use it.
I have one advise though. In my opinion it is better to leave the JAR with the actual ETL code (and not making it part of pentaho by adding it to /lib or /libext) and execute it using a shell command - something like java -jar MyProg.jar
Otherwise you will have strange problems:
- having an older version of the Jar in the pentaho installation folder
- harder installation because that jar is not where the kjb and kjt files are
- if pentaho is installed with a different user than the one deploying the ETL he might not have rights to access /lib and /libext folders
- If you have more complicated java code and logic it is better to keep it in the jar instead of in a transformation (having java code in two places is a maintenance hell). So adding the jar to pentaho gives you no benefit over just calling java -jar MyJar.jar