Google-search – teach Google that when I say “Java”, I mean “Java 6”

google-search

I use Google a lot to look for Java documentation.

Example: If I want to find documentation for HashMap, I just google Java hashmap and Google knows to redirect me to the javadoc page.

However, it usually directs me to Java 1.4 or Java5 documentation, and I want Java6 documentation.

If I google Java 6 hashmap, it works fine; the problem is I keep forgetting to put 6 and have to search twice.

Can I teach Google somehow that when I say Java, I mean Java6? (I have a Google account, so if it is somehow configurable via an account, I'm open for suggestions.)

Best Answer

I had the same problem/wish. This is what I did to solve it:

  • Install this Greasemonkey script (which is a bit out of date, since it was made before Oracle bought Sun)
  • Edit the script slightly to make it work with Oracle's website. This is the edited script:

    // ==UserScript==
    // @name           Java 6 Documentation Redirect
    // @namespace      http://freecog.net/2007/
    // @description    Redirects to the Java SE 6 documenation from older pages.
    // @include        http://download.oracle.com/javase/*
    // ==/UserScript==
    
    var old_loc = loc = window.location.href;
    loc = loc.replace(/\/javase\/[^\/]+\/docs\//, "/javase/6/docs/");
    if (loc != old_loc) window.location.replace(loc);
    

The only changes are to the @include URL and the regex.

That way, whenever you open a Java documentation page, it redirects to the Java 6 version. If you ever really need to see an older version, you can temporarily disable the user script.