I feel bad.. am I wrong?

So I’ve been with my boyfriend for almost 4 years. During that time, he hasn’t maintained a steady job and has started classes but stopped going each time. I always keep my opinions to myself because he gets so defensive but I just couldn’t anymore.. so I sat him down and basically told him that if he doesn’t get his shit together then I have to move on. He said that his feelings are hurt by what I said but he wants to be with me and wants better for us and himself so he’ll get himself together. I didn’t mean to hurt his feelings and now I feel bad. Should I have went about it a different way?