Java snippet class problem


i have some problems with the Java-Snippet.

p.ex. I want to use the java-class "HashSet" or "ArrayList" in it.

As Java Snippets only accept int,long,string,double or Arrays of that types as output, I converted my treated HashSet or Arraylist (or whatever) into an Array again (with the "toArray()"-method) which should finally be the output.

so far that seems to be ok, as the java snippet compiles the code... but if i want to look up my results with the Interactive-Table-node, there only appears one "?" in the new appended column as result.

so do I have to develop nodes in the eclipse-knime environment to be able to use Types like "HashSet" or "ArrayList" or can I address this problem by using the "add additional libraries"-option in the java-snippet? it doesn´t seem to be a problem with the display of the interactive table...

thank you for your replies!

You have to use the full package, such as java.util.HashSet; the '?' indicates missing values, that is, your script failed for this particular row or your returned null on propose?!?


thanks for the reply. yes, I already tried to "import java.util.ArrayList" into the code of my java snippet.

but then there appears the following error:

"Syntax error on token "import", assert expected"

I don´t think that the script failed as it always behave the same way, even if I try this with simple examples (without returning null).

So according to my experience the Java Snippet is not compatible to all possible java types...


Hello stud,

I think you cannot your import statements in the expression area (and I think you cannot use it in the header area either), you have to specify always the full class names except for some pre-imported (for example java.util.*) classes.