It can be done. It is just not very practical, you are better off writing C.
The only situation I can think of where Java would be right fit is where you have an application with a lot of logic and just a small part that needs to be highly optimized.