While I admit that I don't know the details of this issue, I think that the judge is just interpreting state law. Corrections welcome.
NJ does NOT have a marriage law for gays.
Their legislature DID pass it into law but it was VETOED by Gov. Chris Christie who insisted that the people of NJ should decide.