The Hamiltonian associated to the mass variable system is constructed from first principles through finding a constant of motion of the system. A comparison is made of the classical motion of a body with its mass position depending in the (x,v) space and (x,p) space which are defined by the constant of motion and the Hamiltonian, for a particular model of mass variation. As one could expected, these motion looks different on these spaces. The quantization of the harmonic oscillator with this mass variation is done, and a comparison is made by using the usual Hamiltonian approach with the proposed quantization of the constant of motion approach. This comparison is done at first order in perturbation theory, and one sees a difference between both approaches which can, in principle, be measured.