Three-dimensional (3D) GaN is a III-V compound semiconductor with potential optoelectronic applications. In this paper, starting from 3D GaN in wurtzite and zinc-blende structures, we investigated the mechanical, electronic, and optical properties of the 2D single-layer honeycomb structure of GaN (g-GaN) and its bilayer, trilayer, and multilayer van der Waals solids using density-functional theory. Based on high-temperature ab initio molecular-dynamics calculations, we first showed that g-GaN can remain stable at high temperature. Then we performed a comparative study to reveal how the physical properties vary with dimensionality. While 3D GaN is a direct-band-gap semiconductor, g-GaN in two dimensions has a relatively wider indirect band gap. Moreover, 2D g-GaN displays a higher Poisson ratio and slightly less charge transfer from cation to anion. In two dimensions, the optical-absorption spectra of 3D crystalline phases are modified dramatically, and their absorption onset energy is blueshifted. We also showed that the physical properties predicted for freestanding g-GaN are preserved when g-GaN is grown on metallic as well as semiconducting substrates. In particular, 3D layered blue phosphorus, being nearly lattice-matched to g-GaN, is found to be an excellent substrate for growing g-GaN. Bilayer, trilayer, and van der Waals crystals can be constructed by a special stacking sequence of g-GaN, and they can display electronic and optical properties that can be controlled by the number of g-GaN layers. In particular, their fundamental band gap decreases and changes from indirect to direct with an increasing number of g-GaN layers.