Question:
How to get screen resolution (screen size) using Java?
Code:
import java.awt.*; public class GetScreenSize { public static void main(String[] args) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); System.out.println("Height: " + screen.height); System.out.println("Width: " + screen.width); } }
Output:
$ java GetScreenSize Height: 1200 Width: 1920