Accessing files in Java Snippet on KNIME Server

I have a .js file which I want to access on KNIME Server in a Java Snippet, how can I access the file, where could I store it and how would the path look like?

Thanks

Hi,
I would suggest you put a folder inside your workflow that you call “files” and then use the List Files node to list files in knime://knime.workflow/files. You will get a table with one row that is the actual path to your js file. Turn that into a flow variable using Table Row to Variable and pass that to your Java Snippet node. There you can then read the file.
Kind regards
Alexander

4 Likes

Gonna try this as soon as KNIME Core is installed on our server. Thank you!

Hi there @tbtt,

how about drop folder inside Java Snippet folder?

Br,
Ivan

1 Like

Hey Ivan,
I tried this, and it works on the local machine, however on the server it doesnt work. When I open the Workflow as a new job on the server, the variable in the Java Snippet is gone.

Hi there @tbtt,

what do you mean it doesn’t work on Server? You deployed workflow on Server, ran it and got error or?

Br,
Ivan

Hi Ivan,

let me clarify:

I deployed it on the server, rightclick->open as new job on server and try to run it. But the Java code isn’t working (I guess because the variable can’t be resolved), if I open the Java Snippet Node,

the variable is not appearing in the list.
If I open the deployed version as a local copy, the code works and the variable appears in the list. Thanks!

Hi there @tbtt,

I see. Will check it and get back to you.

Br,
Ivan

Hi @ipazin and @tbtt,
A developer told me that this feature is deprecated and should not be used anymore. Can you try to use my idea of using the List Files node?
Kind regards,
Alexander

2 Likes

Hey Alexanders,

finally was able to test your solution, worked out perfectly, thanks!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.