Weak KAM theorem for Hamilton-Jacobi equations