You can add java functions into custom functions.

Actually, you can also add java class files or jar file.
You will find "additional libraries" button (to import jar or class) at custom page.

For example: EJS use many libraries from opensourcephysics project and other open source code.