It depends on what you want to hack; but generally you need a lower
level programming language like C/C++.
Java protects programmers from many of the things that are easily
exploitable. You could probably do some things in servlets/jsp with http
return attacks, but I don't know what kind of ninja hacking you could do
with it.
If you want to learn about hacking to move into computer security you
really need to step down. I would recommend C over C++ as you can
program directly for the hardware layer even on simple devices like
embedded systems and drivers ... which is where the most critical kind
exploits can be found.