I have reviewed your test project and here are my findings.
The reason why you weren't able to import the CoolFunctions class is that in Java you cannot import types from an unnamed (default) package
. This is the case when you put your *.java files directly into the trans folder. So, in order to be able to import it, your java file has to be in a subfolder of the trans folder and contain a package statement
. The package name should ideally respect the Java package naming conventions
Although this was the main issue, I've found more, whereas some had the potential to confuse you but some could render you unable to run your graph(s).1.
Component properties Algorithm
, Algorithm URL
and Algorithm class
are mutually exclusive. Therefore, when you configure more than one of these, there wouldn't be any error displayed but only the one with the highest priority will be used. Their priorities are the same as their order in the component edit dialog. So Algorithm
has the highest and Algorithm class
the lowest priority. That implies there's always only one class that is used as the "core" of the CustomJava component. This behavior might be useful for some complex cases but this doesn't seem to be one of them.2.
Your CoolFunctions class doesn't need to extend AbstractGenericTransform class. Only the class that serves as the "core" class of the CustomJava component needs to do this - Transform class in your case.3.
In Java you don't import files but types (a class in this case). So the correct import statement should look something like import com.companyname.main.CoolFunctions;
instead of import com.companyname.main.CoolFunctions.java;
I noticed you tried to use the myCoolFunction()
method without instantiating
the class it is a member of and referencing the method using the instance name
. I'm not sure if this is because you created the example in a hurry but that wouldn't work. Alternatively you can make the method static
and then reference it using the class name, i.e. CoolFunctions.myCoolFunction();
I hope I didn't forget anything but this should get you going. Attached is your project, modified to be working so you can compare them.