Support Questions

Find answers, ask questions, and share your expertise

Is there any way to compile the java code using external jars present in any other path, not in the library path

Hello,

I want to compile my java code using some external jars that are not included in the nifi lib folder.Is there any way to define a external path in the nifi, from where along with the nifi lib folder, my java code compiler will look into for the code compilation process?

2 REPLIES 2

Super Guru

Can you share some more details about what you're trying to do? How are you compiling/building your code? Are you trying to build a NiFi ARchive (NAR) that contains components such as processors and/or controller services? If so, this blog shows how to set up a Maven project to do so, and you can include your dependencies there (they will be included in the NAR and unpacked when the NAR is loaded).

If instead you need to be able to access JARs at runtime that will not be there during compilation, you can offer a property for "Additional resources" or whatever, and create a classloader at runtime that will include those paths. See ClassloaderUtils.getCustomClassLoader() or ScriptingComponentHelper.setupEngines() for more information. ExecuteScript and JoltTransformJSON are examples of processors that use these methods.

Thanks @Matt Burgess.What i am trying to do is i have a custom processor , that inputs the user custom java code and executes it .If the code contains some external jars, then it should be present either in the nifi lib folder or in the NAR i have.But sometimes the custom code uses some external jars which are not present in both places, so i want some way to compile the java code using external jars that are present on a particular path other than nifi lib using some api.

and