Dylan Wheeler
Dylan Wheeler

Reputation: 7074

Java - Get first and last name of user

Here is my situation.

I am writing a program that will store a database. Currently, the way of identifying the user is by their computer user name. I am very desperate here, so any ideas will work. I am looking for ANY method (doesn't always need to work) for BOTH OSX and Windows computers that will somehow fetch the user's first and last name.

Thank you all in advance!

Upvotes: 0

Views: 1520

Answers (1)

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

Many times, the computer won't even know the user's real name -- you realize that, right? That said, there's a Java system property "user.name" which will always contain the login name, on any system:

String username = System.getProperty("user.name");

That's the only thing you can get with any reliability.

... except for prompting the user. Why not just ask them for their name?

Upvotes: 1

Related Questions