How to use custom java class in a javascript script task?

Is it possible to use my custom java class in a javascript script task like described here for groovy

Scripting | docs.camunda.org?

@nave83 cant you use a Java Delegate instead? if your project is already a spring project, just make your service task implementation as “Delegate Expression” and set it as “${myJavaDelegate}”.
Now in your java project just create a class named MyJavaDelegate with @Component and implement the camunda JavaDelegate interface.

If its not a spring project, select implementation “Java Class” instead and put the full package+class name in the java class field.

The “execute” method of this interface & class will then be called everytime a process goes to this service task, and then you will execute your java custom code.
https://docs.camunda.org/manual/7.15/user-guide/process-engine/delegation-code/