Archive for the 'Java Utilities' Category

Getting The Name Of Currently Logged In User In The System

Kushal Paudyal January 17th, 2010

This little java utility class lets you find the user who is currently logged in (username) to your system.

/**
 * @author Kushal Paudyal
 * www.sanjaal.com/java
 * Last Modified On 2009-06-09
 */
package com.kushal.utils;

/**
 * This class demonstrates how to find the current logged in user on the system
 * in Java.
 *
 */
public class GetCurrentLoggedInUser {

	public void getCurrentLoggedInUser() {

		String currentLoggedInUser = System.getProperty("user.name");
		System.out.println("The Current Logged In User Is: " + currentLoggedInUser);
	}

	public static void main(String[] args) {
		new GetCurrentLoggedInUser().getCurrentLoggedInUser();
	}
}

————-
Here is the output when I run this in my machine:

The Current Logged In User Is: kushalp

Related Tutorials




Sanjaal.com is owned and maintained by Sanjaal Corps, Nepal. The company offers Webhosting and Domain Registration Services, IT Solutions and Business Analysis. Sanjaal.com website features H1B Visa Information, Entertainment Portal, Link Directory Service, Free Articles, Free Open Source Tutorials on Java and J2EE Platform, Digital Photography, High Resolution Picture Gallery and Free Reliable Image Hosting Services. Future plan includes Open Source Software Development Portal, Technical Solutions and Customizable Movie and Music Arena. We would be introducing data backup, data recovery, data hosting and voip solutions. Stay free from phishing – our website does not ask for your credit card and banking information. Happy Surfing!

Blog Widget by LinkWithin

Originally posted 2009-06-09 15:17:43.

  • Share/Bookmark

Next »


Your Ad Here