My textbook says "The amount of thermal energy is found by measuring the temperature of the substance." However, how is this true? Temperature measures only the average kinetic energy of the particles in an object, not how many particles there are. So, for example, imagine a couple of particles in a jar have a super high velocity; thus, the temperature of inside the jar would be very high, but there would not be too much thermal energy because there are only a few particles. The ocean, on the other hand, has many, many particles, but its temperature is lower. However, the ocean has more thermal energy! If this is the case, then obviously temperature cannot measure thermal energy. Why does my textbook say so?
Thermal energy is exactly the average (with respect to the time interval of your measure) of the overall translational kinetic energy of all the particles of your system. This, in turn, can be related to the temperature of your system in case the Hamiltonian is separable into the coordinates of each one of your particles (the equipartition theorem). In particular, the overall thermal energy is proportional to both the number $N$ of particles and their kinetic energies (most of the times it is nothing but the product thereof, after averaging over all the degrees of freedom).
In your example two particles at high velocity may still contribute to the total thermal energy, likewise a system of many more particles where each one of them shares instead very low velocity contributions. You may want to have a look at the wikipedia page which expands what I have stated above in a nutshell.
As pointed out below, there may be additional non-translational and potential contributions to also take into account when averaging for the total thermal energy, rather than only the kinetic terms.