precisiamo intanto che java non è javascript

per la tua domanda, ti basta fare una ricerca (qui o con google) per "screen resolution detection"