Use a stud finder to locate the position of the ceiling joists and mark their locations.
Hold one of the lighting cans against the ceiling and trace the outline onto the ceiling at each location where a light will be installed. Cut holes into the ceiling for the lighting cans with a drywall saw.
Trace an old work electrical box onto the wall where the light switch will go. Place the box between two wall studs. An old work box is used for installing a light switch or electrical socket in a finished wall and is screwed to the wall, as opposed to a new work box, which is used before the walls are finished and is screwed to the side of a wall stud. Cut a hole into the wall for the box with the drywall saw.
Run a 12/2 electrical cable between the main electrical box and the hole for the light switch. A 12/2 cable has two insulated 12-gauge wires, one black (hot) and one white (neutral), along with a bare copper ground wire. Do not wire the cable into the electrical box.
Strip 2 inches of sheathing from the ends of the cable and an inch of insulation from the black and white wires inside the cable with a pair of wire strippers.
Run another piece of cable from the hole for the light switch to the hole for the first recessed light and a cable between each hole in the ceiling. Strip the sheathing and insulation from the ends of the cables in the same method you used for the first section.
Mount the lights into the ceiling. Defer to the manufacturer's instructions for the installation method but, generally, you'll connect the black wire from the light to the black wire from the cable with a plastic twist cap then connect the white wires with a twist cap. The bare wire in the cable is usually wrapped around a ground screw on the fixture; then the end is attached to the bare or green ground wire from the light fixture with a twist cap. Slide the light fixture into the ceiling then press out the tabs on the sides of the light can. The tabs lock the light into the ceiling.
Install the trim and light bulbs into the lights.
Remove the knockout hole on the back of the old work electrical box. Slide the cables inside the hole in the wall through the knockout hole then insert the box into the wall and screw it into place.
Loosen the terminal screws on the sides of the light switch and the ground screw on the bottom of the switch with a screwdriver.
Bend the ends of the black and white wires in the cables into hooks with a pair of pliers. Hook the black wires around the brass or gold-colored screws on the sides of the light switch and tighten the screws. Connect the white wires to the silver terminal screws in the same manner.
Cut a piece of bare copper wire to 3 inches in length from the excess cable. Bend one end of the wire into a hook and connect it to the ground screw on the bottom of the light switch.
Connect the open end of the 3-inch copper wire to the ground wires in the cables with a plastic twist cap. Place the wiring and light switch inside the electrical box and screw the switch to the old work box.
Screw a plate cover to the wall over the light switch. Hire an electrician to connect the line for the recessed lights to your home's main box. Most municipalities prohibit homeowners from doing this unless they have an electrician's license due to the risk of electrocution when working in the main box.