Not ordinarily kept in glass jars (although if you wanted to keep track of yours, it might not be a bad idea), Bandai's Hex Bug robotic toys spend their time skittering around on level surfaces blindly following their limited programming. Just like real bugs.
They're interactive, too. Clap your hands and they change direction. When they bump into each other, or something else, they change direction, too.
(Bandai Hex Bug youtube video)
For myself, I never look at these toys without thinking of their literary ancestors - like the robotic scarab beetle from Raymond Z. Gallun's classic 1936 short story The Scarab:
The Scarab rubbed its hind legs together, as flies will do when at rest. Then, apparently satisfied that it was in condition, it unfolded the coleoptera-like plates over its wings. With a buzz that any uninformed person would have mistaken for that of a beetle, it started out on its journey.
(Read more about scarab robot insect)
Robotic insects are all the rage with researchers; see these articles for more:
Golf Ball Test Robot Wears Them Out
"The robot solemnly hit a ball against the wall, picked it up and teed it, hit it again, over and again...' - Frederik Poh, 1954.
Technovelgy (that's tech-novel-gee!)
is devoted to the creative science inventions and ideas of sf authors. Look for
the Invention Category that interests
you, the Glossary, the Invention
Timeline, or see what's New.