I am going to implement the following code into my app. It doesn't get the name of the user that is currently using the computer, but I can use the function to present a list of users. I'll let the end user decide which user to log out.
Code:
private static String[] loggedInUsers() throws IOException
{
Runtime runtime = Runtime.getRuntime();
String[] output;
Process whoProcess = runtime.exec("who -q");
InputStream inputStream = whoProcess.getInputStream();
InputStreamReader streamReader = new InputStreamReader (inputStream);
BufferedReader bufferedReader = new BufferedReader(streamReader);
String line = bufferedReader.readLine();
output = line.split(" ");
return output;
}