Vertically aligned ZnO-ZnS heterojunction nanowire (NW) arrays were synthesized by thermal evaporation in a tube furnace under controlled conditions. Both ZnO and ZnS are of wurtzite structure, and the axial heterojunctions are formed by epitaxial growth of ZnO on ZnS with an orientation relationship of (ZnO)//(ZnS). Vertical ZnS NW arrays have been obtained by selectively etching ZnO-ZnS NW arrays. Cathodoluminescence measurements of ZnO-ZnS NW arrays and ZnS NW arrays show emissions at 509 and 547 nm, respectively. Both types of aligned NW arrays have been applied to convert mechanical energy into electricity when they are deflected by a conductive AFM tip in contact mode. The received results are explained by the mechanism proposed for nanogenerator.