I assume you're using `su` to login as root, but you don't say what the error is. Are you getting command not found errors or something like 'Xlib: connection to ":0.0" refused by server'? For the first one, your path isn't the same when you su - you may have to type in the full command (e.g. /usr/local/jdk/bin/java).
For the second one, you don't have permission, even as root, to use your user account's X display. Try running the following after you su to root (substitute your username):
/usr/X11R6/bin/xauth merge ~username/.Xauthority
I sometimes end up with the ownership on ~username/.Xauthority changed to root when I do this - so check it after you run the merge.