Meta: all Federal references for 2017 or earlier; the Trump administration plans to 'simplify' the basic 1040 for 2018 by moving most information to additional schedules which will be more work to fill out and provide more opportunities for error.
Lines 9a and 9b on Federal are not exclusive. To be clear, 'ordinary' dividends here does not mean those taxed at ordinary rates (i.e. unqualified); it means (all) dividends funded in the normal way from the busineess' or fund's income/earnings -- which are taxable except for income from exempt bonds (see below), as opposed to a payment which may be labelled dividend or distribution that actually comes out of invested capital (called liquidation if a final distribution and return of capital otherwise) -- which is not itself taxed unless/until it exceeds your basis, but instead reduces your basis and thereby increases your taxable gain (or decreases your loss) on subsequent disposition. Such a distribution is indicated by putting it in 1099-DIV box 3 and not box 1a. This categorization often can't be finalized until full-year accounting is complete, so you may receive payments during the year called dividends that turn out on your 1099-DIV to actually be return of capital.
Thus Federal 9a includes all dividends from Schedule B part II, which in turn should include all amounts from 1099-DIV box 1a; 9b includes the part (subset) of 9a that is qualified and taxed at lower rates. The part potentially qualified is shown in 1099-DIV box 1b, but you must check whether all the requirements are met, like holding period. All of 9a is added into gross income and thus affects (total) taxable income, but when you compute tax using the Qualified Dividends and Capital Gain worksheet on page 44 of the general instructions or the Schedule D workseet in the Schedule D instructions the part in 9b is subtracted from the amount of income taxed at normal rates and added to net long-term capital gains to determine the amount of income taxed at preferential rates.
Since NJ doesn't distinguish qualified vs unqualified dividends, normally the amount on Fed line 9a goes to NJ line 16 with the following exceptions:
if you received dividends from a mutual fund representing interest on US Treasury securities, that is taxable for Fed (and included in Fed Schedule B and line 9a) but not taxable for NJ, so it must be subtracted
if you received dividends from a mutual fund representing interest on securities issued by another state (not NJ) or subdivision, that is not taxable for Fed but is taxable for NJ, so it must be added
if you received distributions from a mutual fund for short-term capital gains, for Fed those are included with regular dividends (on Schedule B-II and line 9a) while for NJ they are excluded (subtracted) from line 16 but instead listed on NJ Schedule B and included in (added to) line 18
The first two of these items are noted as differences betwen Fed and NJ in the boxes on p18-19 (PDF p20-21). If you hold a fund that invests entirely in one set of issuers then the amount you need to shift is simple; if the fund invests in a mixture of securities then your 1099 package should have included a sheet showing the percentage of its net income derived from each state and Federal and you apply those percentages to the distribution amount to determine the fraction that needs to be adjusted. For bonds you hold directly NJ lines 15A,B may similarly vary from Fed lines 8a,8b by making US securities exempt but those from other states taxable.
Mutual fund distributions of long-term capital gains, and gains and losses you incur directly (e.g. by selling a security or mutual fund holding), are reported on Fed Schedule D and line 13 and NJ Schedule B and line 18. The instructions for line 16 on p21 (PDF p23) mention capital gains distributions but do not specifically refer to the different handling of short-term gain distributions -- and once in the past I got caught by that one.