Hamilton-Jacobi approach for first order actions and theories with higher derivatives