System information Learn programming Java

Lesson:

Additional Libraries


Exercise:

System information


Objetive:

Create a program that shows specific system details, including the computer name, domain name, and the username of the user who is currently logged in.


Code:

public class Main
{
	public static void main(String[] args)
	{
		String machineName = Environment.MachineName;
		String domainName = Environment.UserDomainName;
		String userName = Environment.UserName;

		System.out.printf("Machine name: %1$s" + "\r\n", machineName);
		System.out.printf("Domain name: %1$s" + "\r\n", domainName);
		System.out.printf("User name: %1$s" + "\r\n", userName);
	}
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.