# Reading installation/global variables in java

**URL:** <https://forum.universal-robots.com/t/reading-installation-global-variables-in-java/22555>\
**Category:** Java\
**Created:** [July 8, 2022, 2:08pm UTC](https://forum.universal-robots.com/t/reading-installation-global-variables-in-java/22555 "2022-07-08T14:08:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon25659393](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon25659393](https://forum.universal-robots.com/u/anon25659393)\
**Post date:** [July 8, 2022, 2:08pm UTC](https://forum.universal-robots.com/t/reading-installation-global-variables-in-java/22555/1 "2022-07-08T14:08:34Z")

</div>

Hey, is there any way to read variable values in java code? For example using some kind of daemon?  
For example I have a variable “i\_var\_25” set up in Installation menu, and now i’d like to display the value for that variable in the UI. Is that possible?

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [July 8, 2022, 2:27pm UTC](https://forum.universal-robots.com/t/reading-installation-global-variables-in-java/22555/2 "2022-07-08T14:27:59Z")

</div>

According to @jbm in this post: [Reading Installation Variable Values to URCap - #3 by chris.briedenhann](https://forum.universal-robots.com/t/reading-installation-variable-values-to-urcap/3961/3)

No. The value only exists to Polyscope when the program is running. You may be able to pull the value via the ScriptExporter when the program is actually running using the secondary interface, but I haven’t tried that for myself, so it might not work either.

---

<div class="post-metadata">

**Author:** ![anon25659393](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@anon25659393](https://forum.universal-robots.com/u/anon25659393)\
**Post date:** [July 8, 2022, 3:25pm UTC](https://forum.universal-robots.com/t/reading-installation-global-variables-in-java/22555/3 "2022-07-08T15:25:57Z")

</div>

Okay, apparently there is a way to do this via an undocumented command in the dashboard server:

> [@Possible to obtain the value of variable on dashboard server](https://forum.universal-robots.com/t/possible-to-obtain-the-value-of-variable-on-dashboard-server/15637):
>
> Hi, I have happend to find dashboard command to obtain the values of variables that is undescribed in manual. This feature is very useful for checking the state of robot program flow remotely! ex: getVariable var\_1

So to get this working, you would have to build a python daemon.

```auto
#!/usr/bin/env python

import socket
import time
import sys

import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer

def getVar(variableName):
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.settimeout(2)
	s.connect(('127.0.0.1', 29999))
	cmd = 'getVariable ' + variableName
	cmd = cmd + '\n'
	print(cmd)
	s.sendall(cmd.encode())
	rcvd = s.recv(4096)
	return rcvd

server = SimpleXMLRPCServer(("127.0.0.1", 12345))
server.register_function(getVar, "getVar")
server.serve_forever()

```

Then you’d have to put this daemon in the resources folder in your urcap directory, register the daemon service and then call this daemon out from the java code and it should work.

But haven’t tested it yet so can’t be 100% sure
