ask user to input variable value in Java edit variable

I wanted to ask for a syntax to ask the user to input the value of an already created variable using Java edit variable. I am using syntax:

javax.swing.JOptionPane.showInputDialog(null, “variable_name”);

But it seems to cause KNIME to crash everytime I try to configure before even executing the node.

Hi @ahmedbasiouny, welcome to the forum.

I’ve never tried prompting the user from a java snippet, although I know that it is possible to output a message using JOptionPane.

Can you post the actual snippet code that you are using please and we can see if it can be made to work…

Also, when you say it causes KNIME to crash, do you mean the whole application fails, or do you mean an error on the workflow?

hi @takbb
Thank you for replying. You could find the whole syntax below. “Zeitraum” is my input variable that i want to change using the input variable by the user.
It causes the whole application to crash. A window pops up asking for the value, but then i cannot enter any value and the application stops working.

knime 1

Hi @ahmedbasiouny , you’re right… it does cause all of KNIME to crash… lol…

so while waiting for it to reload, I found this post by @qqilihq , (who is an expert in these things).

I have pasted a screenshot of that post here, highlighting something that I think might be very important. It’s the checkbox at the bottom of the java snippet dialog. Don’t press Apply or OK without making sure that’s checked!

I’ll be giving ita try when KNIME comes back, you might wish to do so too :wink:

(By the way, have you got ‘auto-save’ switched on? It’s definitely a good idea when living life on the edge :slight_smile: )

[Edit: it now works when I try it. Hope it works for you too!]


Hi @takbb ,
Wow! It seems to have fixed the issue :smiley:
Thank you so much for your help! :slight_smile:


You’re welcome, and thank you for validating the solution, although really I feel I’ve “stolen” this one. All credit to @qqilihq .

1 Like

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