views:

163

answers:

4

In Java5, is there a way to get the full name of the user that is running the application using only JDK APIs? (I know about JAAS and third-party libraries, but they might not be installed on the target system).

I know about System.getProperty("user.name") but that returns the user ID not user NAME.

+1  A: 

That's as good as you're going to get I'm afraid.

Tom
+6  A: 

The concept of a user's "full" name is OS dependent so there is not a way to get it using standard Java APIs.

Alex B
"The concept" ? I thought all operating systems have a user *ID* and a user *NAME*. Maybe the _implementation_ might be different, but the concept is universal.
florin
Not all operating systems have more than a user ID. All the major ones that people run on their desktops do have a concept of user name, but there are other OS's that don't.
Eddie
+3  A: 
import java.util.Scanner;
...

System.out.println("Please enter your full name: ");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();

;)

Henry
+2  A: 

As a side note. In one of my systems we get the System.getProperty("user.name") and with the ID query the USERS table (in an Oracle DB) to get the rest of the needed info.

northpole