Adding to this, the bottle has a neck leading to an opening narrower than the body of the bottle, for controlled pouring of liquid. The jar’s opening is about the same size as the body of the jar, to allow solid contents (or a mix of solid and liquid contents) to be spooned out.
No doubt there are many many ambiguous examples, though.
Aspirin has traditionally been sold in containers with an opening smaller than the body of the container, so it’s a bottle. With peanut butter, the opening is about the same size as the container, so it’s a jar.
English is highly idiomatic, but these two examples actually fit the usual pattern of usage.
The terms overlap. The quintessential jar is a mason jar. The quintessential bottle is a longneck beer bottle. But some items like pill bottles are more like small jars even though they’re called bottles. And then there are jugs, pots, flasks, beakers, vats, flagons, vessels, basins, tubs, urns, buckets and amphorae.
I don’t envy English language learners. Native speakers can’t even sort this out. Wait until you find out what “inflammable” means.