System information Java Exercise - Java Programming Course


System information


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.

 Example 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 - Programming Tutorials and Courses © 2024 All rights reserved.  Legal Conditions.