As an improvement of the conventional misfit dislocation theory, a theoretical self-consistent method is presented for a study of the heterojunction. Although the interaction between two adhesive crystals is still effectively described by the gamma-energy function, however, the period appearing in the gamma-energy function is no longer predetermined as is usually done but treated as a parameter needs to be determined in a self-consistent way. Because the period is actually the Burgers vector of the misfit dislocation, the self-consistent method is significant for the dislocation- based heterojunction theory. As an illustration, the theory is applied to the heterojunction of two-dimensional materials AlN and BN. It is found that for the AlN/BN heterojunction, the period determined from the minimum-energy principle is very close to the value given previously. Published under an exclusive license by AIP Publishing.