||The dynamics of learning in neural networks is a complex problem. Though much progress has been made in on-line learning in the past, they were based on some unrealistic assumptions. For batch learning they were applied only to simple learning rules. Here we use the cavity method to study the dynamics of batch learning of random examples, using the Adaline rule as our starting point. Many results are derived, including the average local fields, correlation functions, the training error and the test error. The theoretical predictions are well supported by simulation results. This method can be applied to any learning rule.