Welcome to the forun Daniele.
First off, node-red uses JavaScript not Java, they are two different things.
It would be very helpful if you let us know what vrsion of Node-red and node.js you are using (you can get this from the startup log) and could export your flow and attach it to a reply so someone could actually see what you are doing. In order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json