In opposing Peter's use of the sword, Jesus disapproved the use of violence in that specific situation.  He did not disapprove all use of the sword.  He told Peter to put the sword away because he did not want the apostles to oppose his immediate mission, i.e., to die on the cross.