In this article, the J85-GE-21 turbojet engine for an altitude of 1000–8000 m, with the speed of 200 m/s and at 10, 20, and 40 °C, was provided, and then, based on the objective functions, the above system was optimized using particle swarm optimization method. For the purpose of optimization, the Mach number, compressor efficiency, turbine efficiency, nozzle efficiency, and compressor pressure ratio were assumed to be in the range of 0.6–1.4, 0.8–0.95, 0.8–0.95, 0.8–0.95, and 7–10, respectively. The highest exergy efficiency of 73.1% for different components of the engine at sea level and speed of 200 m/s belonged to the diffuser. Second and third to it were nozzle and combustion chamber with 68.6 and 51.5%, respectively. The lowest exergy efficiency of 4% belonged to the compressor, and the second to it was the afterburner with 11.6%. Also, the values of entropy production and efficiency of the second law of thermodynamics were 1176.99 and 479 K/W, respectively, prior to optimization, which were respectively changed to 1129 and 51.4 K/W postoptimization. Obviously, the entropy production is reduced, while the efficiency of the second law of thermodynamics is increased.