The easiest way to achieve this is implementing both urcaps in one urcap package and add a singleton class to that package which both urcaps can communicate with. There is also a interface for urcap communication. See this post
There are also a ton of threads on how to use global (robot) variables in urscript, installaion nodes and for communication (which i wont recommend if you need it on the java layer)