You'll need to download the Java Platform first, before you can run any programs that you'll write. Get it for free from the official source:
http://www.oracle.com/technetwork/ja...ads/index.html
Next you'll need an "IDE." That's the program environment where you will write, test, and run your code. A good one is the Eclipse IDE for Java, but it's by no means the only one. Use google to find one.
All of this is free. You might want to invest in a book that teaches Java if you can find one for good deal, but otherwise you can learn a lot online.