Is there a way to get user's UID on Linux machine using java? -


is there way user's uid on linux machine using java? i'm aware of system.getproperty("user.name"); method, return's user name , i'm looking uid.

you can execute id command , read result.

for example:

$ id -u jigar

output:

1000

you can execute command by

try {     string username = system.getproperty("user.name");     string command = "id -u "+username;     process child = runtime.getruntime().exec(command);      // input stream , read     inputstream in = child.getinputstream();     int c;     while ((c = in.read()) != -1) {         process((char)c);     }     in.close(); } catch (ioexception e) { } 

source


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -