In this paper, we study Fritz John type optimality conditions for constrained nonlinear programming in which equality and inequality constraints are together present. We introduce a generalized Fritz John condition which is necessary and sufficient for a feasible point to be an optimal solution under weak invexity. In particular, by combining the introduced generalized Fritz John condition with the invexity with respect to different functions, we obtain sufficient optimality conditions which extend and generalize various results in the literature, and their importance and usefulness are illustrated on examples.