Externality and Hamilton-Jacobi equations