You need to compile the above code with JDK and then create a jar file with [b]jar[/b] command.
Then you can add the jar file to the EJS.
Click the button at the top right corner, below the cross(close) button
(the same place where you can select "Add screen capture tools ..." options)
and you will find [b]JAR Libraries[/b] in the [b]Options and files[/b] tab,
click check marker to select jar file to add to EJS library.
And add import statement (just one line above JAR Libraries.)
Then, you can use those functions defined in the jar anywhere inside EJS.

Please check out second post at [url=]EJS version of Fourier Synthesis (You can hear the sound,too!)[/url]
I add my own sound java code (as an external jar library).