Basic Naval Academy commitment is also 5 years. That is for pretty much anything except aviation (Surface, Subs, Marine Corps ground). Aviation has it's own commitment based on what type you enter. It used to be that jets had an 8 year commitment and helos and big wing were 7, but I think all pilots are now at 8 years. NFO (Naval Flight Officer), which can be in a few different aircraft, is a 6 year commitment.
Those are all based on completing flight training and getting your wings. If you quit or get bounced then you are still on your 5 year basic commitment from the academy. Flight school for Navy varies in duration depending on pilot or flight officer and then also by type of training. Jet training takes longer than helo.