The ALICE experiment at the LHC has studied inclusive J/$\psi$ production at central and forward rapidities in pp collisions at $\sqrt{s} = 7$ TeV. In this Letter, we report on the first results obtained detecting the J/$\psi$ through its dilepton decay into $e^+e^-$ and $\mu^+\mu^-$ pairs in the rapidity range |y|<0.9 and 2.5<y<4, respectively, and with acceptance down to zero $p_{\rm T}$. In the dielectron channel the analysis was carried out on a data sample corresponding to an integrated luminosity $L_{\rm int}$ = 5.6 nb$^{-1}$ and the number of signal events is $N_{J/\psi}=352 \pm 32$ (stat.) $\pm$ 28 (syst.); the corresponding figures in the dimuon channel are $L_{\rm int}$ = 15.6 nb$^{-1}$ and $N_{J/\psi} = 1924 \pm 77$ (stat.) $\pm$ 144(syst.). The measured production cross sections are $\sigma_{J/\psi}$ (|y|<0.9) = 12.4 $\pm$ 1.1 (stat.) $\pm$ 1.8 (syst.) + 1.8 -2.7 (syst.pol.) $\mu$b and $\sigma_{J/\psi}$ (2.5<y<4) = 6.31 $\pm$ 0.25 (stat.) $\pm$ 0.76 (syst.) +0.95 -1.96 (syst.pol.) $\mu$b. The differential cross sections, in transverse momentum and rapidity, of the J/$\psi$ were also measured.