Linked Questions
15 questions linked to/from Java current machine name and logged in user?
69 votes
3 answers
154k views
Getting the computer name in Java [duplicate]
I was wondering if there is a way to get the computer name in Java? I have seen several answers that feature java.net.InetAddress. However I was wondering if there is a way that does not use the ...
0 votes
1 answer
150 views
Extract network user login in a java web application [duplicate]
Is there a way to extract the username logged into the network from a Java web-based application?
0 votes
0 answers
57 views
How to find out your computer name with Java [duplicate]
So I have this program and I would want to have Java figure out the username by itself. import java.io.*; import java.nio.file.Files; public class Demo { public static void main(String[] args) ...
373 votes
13 answers
480k views
Recommended way to get hostname in Java
Which of the following is the best and most portable way to get the hostname of the current computer in Java? Runtime.getRuntime().exec("hostname") vs InetAddress.getLocalHost().getHostName()
40 votes
4 answers
93k views
How to get Windows username in Java?
So what I am trying to do is let my Java find the user's name that windows is logged in with, so when I would say such a method, it would return the users name, like I use it in the User called Noah, ...
30 votes
4 answers
88k views
Get DNS name of local machine as seen by a remote machine
I'm making a peer-to-peer instant messaging application. Currently, if UserA.pool.net says "hello" to UserB.pool.net, User A sees "You: hello" and User B sees "UserA.pool.net: hello". Rather than ...
3 votes
3 answers
3k views
How to get current user name of Linux in Java
I have a Selenium tests written in Java which runs as Jenkins job. I need to have chmod set up to 777 cause otherwise it throws me an error. But I would like to set up chmod properly to somenthing ...
6 votes
2 answers
2k views
Can user.name be spoofed
To get the name of the current user in a Java program, you can simply fetch the value of the user.name system property: System.getProperty("user.name"); But how secure is that? Can a user executing ...
1 vote
2 answers
4k views
Fetching user name (windows) from a java application
Problem: I am logging into a virtual machine(RDC) using the below credentials: The user is part of a domain group called as teldept user:147852 pass:helloworld when i try to get the user details ...
1 vote
1 answer
3k views
Get windows user logged in on WebApp (JAVA)
I´ve been stucked with this task for days now.. In the login form of my web application, before the user could enter the username and password, I want to receive in the request the username of his ...
0 votes
0 answers
1k views
Play Framework 2.4.0 - How to retrieve the logged in user in play-java application
I've created a play-java web application, with the default Application controller: package controllers; import play.*; import play.mvc.*; public class Application extends Controller { public ...
0 votes
1 answer
759 views
How can I get network user name in java? [duplicate]
I need get a network user name, but I don't know how! I try "System.getenv("USERNAME")", "System.getProperty("user.name")" and "new com.sun.security.auth.module.NTSystem().getName()", but didn'...
2 votes
2 answers
332 views
Running "who -m" command from Java yields empty result
I am trying to find the current logged in username from Java. Process p; try { p = Runtime.getRuntime().exec("who -m"); p.waitFor(); BufferedReader reader = new BufferedReader(new ...
-1 votes
1 answer
292 views
how do i get the username from new com.sun.security.auth.module.UnixSystem().getUsername()?
i need help trying todo this--> type variableName = new com.sun.security.auth.module.UnixSystem().getUsername() public class Main { public static String CodeKey="RAWW"; public ...
0 votes
3 answers
217 views
Java code executor
When I executed my java class it turned out that I don't have some privileges when I try to access a file and I've got false: file.canRead() In order to get necessary rights I want to know who ...