You would NEVER want to allow someone to type the root password on the command line. Why? Typing 'history | grep su' or 'history | less' would show it. This is a major security issue if you were to do it.
Use sudo. You can set up sudo so that anyone else can run certain commands without even entering a password.
Type 'visudo' to create an '/etc/sudoers' file. Make it contain something along the lines of:
ALL = ALL NOPASSWD: /sbin/ifconfig
Let me explain this a little. The format for the /etc/sudoers file is very simple
username host = command with the NOPASSWD statement optional. So all users from all hosts can run the ifconfig command without entering a password. If you wanted them to enter a password, they would just have to enter their own password.
You can also restrict it to a certain user or a certain host (computer) very easily. Make sure to create the '/etc/sudoers' file using the 'visudo' command, sudo gets really pissed off when there are errors in this file. I love using sudo.
Now, code your java program to create a system call to 'sudo ifconfig' and it will work. Beautiful, huh?