Check if application is run under root privileges?

Hello,

My Java application is going to use some low-level networking functions written through JNI. For this, it needs to be run as root (Linux). Is there a way to check within the application if it is run with root privileges? (Or administrator privileges in Windows) If it is not, then it would disable certain options.

Thanks.

[348 byte] By [SuperDarioa] at [2007-11-27 4:13:10]
# 1
As far as I know, you can only reliably check the user name (not group or permissions). Perhaps checking for "root" or "Administrator" is enough, perhaps not. System.getProperty("user.name") will get this info.Otherwise, I believe you'll have to turn to JNI for this as well.
Herko_ter_Horsta at 2007-7-12 9:19:20 > top of Java-index,Java Essentials,Java Programming...