Java code: Open IE browser and close it

I want to refresh my blog on Sohu to increase the visitor count. The following is the code for open IE browser and then close it. This will be done every 5 seconds, and in one day the count should be able to increase 3600*24/5 = 17280. So if you open your computer 10 days,  the count will become 172800. That will be a nice number.

Here is the Java code to open and close IE:

public class OpenClose {
	public static void main(String[] args) {
			try {
				Process p = Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe \"\"");
				System.out.println("Return value was " + p.waitFor());
			} catch (Exception e) {}
Category >> Real Methods  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";

  1. mohit on 2013-7-3

    Exception is coming how to remove this… runtime exception are coming

  2. rohit on 2013-9-23

    it’s not working p.destroy();

  3. pranish shrestha on 2014-6-30

    how to use Desktop class to open the default browser and close it??

  4. Ankita on 2016-3-2

    Hi. I tried the above code. Its working but I dnt want to open the browser every 5 sec now. so how do I stop running the code?

Leave a comment