Use the command- driver.manage().window().setSize(new Dimension(int value1, int value2));
where driver is WebDriver type.

ex-

import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ResizeWindow {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().setSize(new Dimension(400,600));
    }
}

 

Source: http://selenium-makeiteasy.blogspot.com