Dear all,
I'm having trouble getting the system property user.name (which we need in our ant scripts) on our CentOS box. :(
When running the program below thru
java dumpproperties2
it prints "user.name='?'" on our CentOS 4.3. On win32 it works. It turns out that if you add the account corresponding to the EUID to /etc/passwd it works correctly. However, we don't use passwd authentication but an enterprise wide LDAP-system. Our /etc/nsswitch.conf says:
passwd: files ldap
One work around is to replace the java executable with a script that does
/path/to/jdk/bin/java -Duser.name=$USER -Duser.home=$HOME $@
Used jdk is j2se 1.5.0_13 Linux 32-bit.
Some questions for the experts:
1) Is there any other way?
2) Is it a known issue that Linux versions of the jdk just looks in /etc/passwd to map uid to user name (and home dir) instead of doing what the rest of the system, like whoami, does? I haven't found anything in either the readme or installation instructions, nor in the bug db.
Br, Jesper Tr�g�rdh
public class dumpproperties2 {
public static void main(String[] args) {
String s = System.getProperty("user.name");
System.out.println("user.name='" + s + "'");
}
}