You’re potentially asking 2 things there. Do you want to get the joint positions using the Java API, or are you trying to run a URScript command and have it return the result back to Java?
Something like getting the connection and asking for the position continuosuly.
Regardless, you’ve further defined the scope of your question, which makes it somewhat of a moot point, since you want to read the joint positions CONTINUOUSLY, as opposed to capturing them at a single moment in time (like at the time of pushing a button on the UI). There is no built-in API command for this in Java. You would have to write in a Python (or similar) daemon and implement the Realtime Data Exchange (RTDE) to poll that sort of data constantly. There are resources on UR’s website with examples on how to go about doing that, but it’s not a trivial process.