NJ can tax all your income up until the day you established your domicile (your permanent home) in NY. So, if you moved to NY during January, you would file a part-year resident return in NJ and a part-year resident return in NY. Any excess NJ withholding would be refunded to you.
If you established your NY domicile prior to January 1, you would file a non-resident NJ return showing zero NJ income, and all your NJ withholding will be refunded. (But if you worked in NJ after your move, your non-resident NJ return would have to show your NJ earnings.)