The ergodic limit for a viscous Hamilton-Jacobi equation with Dirichlet conditions