I'm trying to make a program that submits a search query to Google and then opens the browser with the results. I have managed to connect to Google but I'm stuck because I don't know how to insert the search query into the URL and submit it. I have tried to use HtmlUnit but it doesn't seem to work.
This is the code so far:
URL url = new URL("http://google.com");
HttpURLConnection hr = (HttpURLConnection) url.openConnection();
System.out.println(hr.getResponseCode());
String str = "search from java!";