You can store it in a jar, but this isn't an optimal solution. Coffee should be stored in containers that have a 1-way degassing valve, which allows the off-gassing from the coffee beans to escape, but doesn't let oxygen in. You could modify the mason jar lid to install a coffee degassing valve, if you're feeling particularly crafty. This doesn't solve the issue that mason jars are transparent, and sunlight can cause expedited degradation of roasted coffee beans.