Yes, but you need to know the boundary of the law. You cannot just shoot people in your house; but someone break your window to come in, you can - according to the related law.
Check the law yourself or talk to a knowledgeable lawyer. This reply is not a legal advice.