Once you get to the download site. Always, verify URL is legit in address bar before downloading.
Here's the legit Java site for example: Download Free Java Software
Choose (Custom) install, and not (Recommended) install.
Remove ticks or keep declining offers as (derekimo) suggested.
Watch out for tricks, they try many different methods you slip one in on you.
Always, try to download from the software makers website, if possible. Many of them don't hoist advertisements.
Third party download sites, get paid from advertisements.
After downloads, go to add/remove programs and check for odd entries with the same date as the new download.
Entries such as, toolbars, sweetpacks, conduit, wapam, etc.
Adware usually slips into there. Although, it can install several other places, too.
Such as, in program files, startups, system32, and services, are just some areas affected.
Sometimes, no matter how careful you are, not to download the wrong stuff. The third party download site will still install their crap.
This is why you always need to look around afterwards.
You may even want to run a few cleaning utilities if you find something that was not there before the download.