I was smoking a MJ joint, and shared it with my friend...
The act of distribution of a drug, also called a controlled dangerous substance (a CDS) is essentially accomplished by the actual, constructive or attempted delivery of the drug. It is the delivery or attempted delivery that constitutes the act of distribution. The passing of the drug, from person to person, with each person knowing that the item being passed is a drug, constitutes the distribution of drugs. Leaving the drugs where another person knows you are leaving them, who then comes and picks them up, is a constructive delivery. Leaving the drugs for some person to pick-up, where the pick-up fails for some unrelated and unanticipated reason, is an attempted distribution. Each can expose you to being charged with the act of distribution of a CDS. Passing that MJ joint, makes you a distributor of CDS.
...I didn't sell it to him, we just shared it.
The fact that you did not charge for the drugs you distributed has no impact on whether you distributed. There is no requirement of an exchange of something of value for the CDS. No money needs to pass hands, just the delivery of the drugs. If you simply pass a shared MJ joint, and there is nothing else that the cops have against you to support other acts of distribution, it is possible to argue for a downgraded offense as part of a plea. In NJ however, it is unlikely that an argument that this was a De Minimus offense (a very minor infraction of the law) is unlikely to be successful. Discuss this with your lawyer before you go to Court.