Some good answers, but another angle:
If you're looking to start a small company, find a niche that you enjoy working on, and then find an even smaller niche inside that niche. Find pain and solve it in a clear and simple way.
An example: a coworker of mine is in his church's band. They needed a way to easily share sheet music online. There are a number of sites that support that, but there's actually a site that focuses on sharing sheet music for church bands.
For a B2B idea:
Companies do performance reviews, right? And everyone hates them because they're annoying and they're overly complex. So we have a major pain we can solve. Now, creating a software product for performance reviews for every company under the sun would be an insane task. Oracle does this and it's a horrible product and we clearly can't compete with them. But how about writing software for performance reviews at small software development companies? Or software that helps conduct performance reviews for small development companies with Scrum teams? Maybe write a plugin for JIRA that allows those supervising the teams to set goals and track them?
So, we went from the huge niche of Performance Reviews which has a bunch of unknown requirements, to a very small well defined niche.
A good book on this subject, since you're a developer:
Start Small, Stay Small: A Developer's Guide to Launching a Startup
About 200 pages and a pretty fast read. It also covers what to do once you've found your niche.