I am trying to implement ARMA model in Java. I have trouble with calculating residuals (white noise) in Moving average part of the model. From the answer on this question (Fitted values of ARMA model) I see that they can be calculated by certain expression: $e_t=X_t-Ar*X_{t-1}-Ma*e_{t-1}$, where $Ar$ and $Ma$ are parameters which you set in program $R$.
My question is how can I calculate or estimate residuals without having parameters $Ar$ and $Ma$? Because the goal of my application is actually to calculate these parameters and use the model for predicting.
Generally I understand residuals as the differences between real and predicted (estimated) values. So how can I estimate residuals if I don't have constructed model yet?
p.s. I looked up to some books and theory, but didn't find any example or exact explanation of what are the values of these residuals.
Thank you in advance.