This study presents a novel approach to integrating combined cooling, heating, and power (CCHP) systems with water desalination for enhanced energy and water management in educational buildings. Two distinct layouts for CCHP and desalination systems are introduced: one prioritizing efficient power generation to meet electricity demands while providing waste heat for desalination, and the other focusing on balancing cooling and heating loads alongside water desalination. Both layouts are tailored to meet the building's energy and water demands while considering operational efficiency. Optimization of these layouts against traditional systems using the bat search algorithm emphasizes economic viability and the gas engine's operational flexibility, which are crucial for partial load operation. In addition, an environmental assessment compares the proposed CCHP-desalination systems with conventional setups, assessing CO2 emission reductions and overall sustainability. The evaluation encompasses key environmental metrics, such as resource consumption and the integration of renewable energy sources. Results highlight significant CO2 emission reductions across various gas engine capacities, with notable enhancements in economic and environmental performance achieved by selecting a 3,250 kW gas engine within the CCHP-desalination system. This choice not only maximizes the annual profit but also reduces CO2 emissions by 57% compared to conventional systems, underscoring the system's sustainability benefits.