Thanks for answers. I made it this way:
JBOSS_HOME=$(ps efax | grep "JBOSS_HOME" | grep java | sed "2,1000d" | sed 's/.*JBOSS_HOME=//' | sed 's/services\/jboss .*/services\/jboss/')
In my working environment JBOSS_HOME always ends with '/services/jboss' so I am cutting everything after that and everything from beggining of listing to 'JBOSS_HOME=' text. Those things are made by sed. sed "2,1000d" takes only first listing if more than one were found.
Greets.