We can't know the structure of a JBoss AS server in advance. Likewise, we can't use the AS's classpath because it doesn't include all libraries.
AS Tools and Runtime Detection use a similar code. I don't know how to improve that.