Java is a powerful but easy to use programming language (not to mention that it’s the language used in most computer programming courses.) Java is a great language and fairly easy once you get everything set up – ಆದರೆ getting everything set up is difficult. That’s what this guide is for.
Getting the SDK
Before you do anything, you have to get the JDK – ದಿ Java Development Kit or Java SDK (Software Development Kit). You need the SDK to write Java programs. Go to this page and click on the JDK download button.
Download the installer and run it. ಅಭಿನಂದನೆಗಳು! The Java SDK has now been installed on your computer.
Getting an IDE
Now that you have the JDK, you can start programming, but you’ll have to do it the old-fashioned way: write code in a text editor and compile it using the command line.
Unless, ಕೋರ್ಸ್, you have an Integrated Development Environment, which is a fancy term for a program that helps you code. Believe me, it’s much, much easier coding using an IDE.
So which IDE should you use? Most people will recommend a couple to you:
- BlueJ is a very simple IDE that’s good for educational purposes, ಆದರೆ not very useful for large projects. Chances are you’ll be aiming a little higher than BlueJ will afford you. Not a bad IDE though.
- JCreator is slightly more powerful, but it’s expensive, and the free version is barely better than coding the old-fashioned way (I’ll tell you, I have to use JCreator in school.) ಇದು clunky ಮತ್ತು lacks a lot of the neat features that the next 2 IDEs have. You might want to pass on this one.
- Eclipse is a powerful, professional editor that a lot of pros use (and don’t worry, it’s free.) It’s very useful, if a little unintuitive, and regarded as one of the best IDEs out there. Definitely worth a look.
- Netbeans isn’t as well-known as Eclipse, but it’s just as powerful and useful. It’s very similar to Eclipse, except it’s slightly easier to use and it has a very nice GUI builder. I personally recommend it, ಮತ್ತು I’ll be showing you how to use this IDE in this guide. You should use either Netbeans or Eclipse.
ಮುಂದೆ ಹೋಗಿ download and install and IDE (just click on the links to go to their sites.)
Making a project
Fire up Netbeans (you can register, but you don’t need to) and click on the box button with a plus sign on the toolbar. That’s the new project ಗುಂಡಿ. I’ll just be showing you how to make a new project – each Java app you make will be its own project. NetBeans will keep all the files in one central place for you.
Create the Java > Java Application, then enter the name of your project – call it anything you like. You can change the other fields but that isn’t really necessary.
And voila! Your project is created. It’ll look a little like this…
You can type what I typed (the line highlighted in blue; click on the image to view it full size) in that space and then click the green arrow button in the toolbar to run your application. (Don’t worry if none of this makes sense to you; you’ll be learning the language soon.)
If you see some output at the bottom of your screen, then everything’s worked – you can now write Java to your heart’s content.
If you want to add a new file, click on the page with a plus sign on the toolbar and select Java > Java Class. (Again, don’t worry if you have no idea what a class is, just go with it.) Enter the name of the file in the next step (if you want to create SomeFile.java, enter SomeFile in the text box.)
Now your screen will look a little like this:
Notice the list of files in the left panel – just click on a file’s name to open it in a new tab. You can have many files – and thus many tabs – open for editing at once. Running your program still works as normal.
That’s all well and good, you say, but I have no idea how to write this Java thing. Do I need a coffee machine?
Getting a book
Obviously, you can’t write Java unless you learn it. If you’ll be taking a course on Java, you can stop right here. ಅಲ್ಲ, you’ll need a good book to learn Java.
Trouble is, most of the books on Java are either incredibly boring, too complicated, or just flat-out bad. Thankfully, there’s an excellent book on Java by an excellent series – Head First Java. (Get it on Amazon.)
If you’ve ever read a Head First book, you’ll agree that Head First books are great. They’re engaging, fun, and packed with useful exercises. No more boring lectures or drab textbooks that are heavier than dictionaries. ಇಲ್ಲ, Head First Java is actually useful and makes Java fun and easy. I used it myself and it was far better than a 9-month course (not to mention that the entire content of the course fit into about 100 pages of this book.)
Seriously, I can’t stress how great Head First is. Go ahead and buy it, and you can jump right in. When you start a new exercise, make a new project and add as many files as you need to.
Head First assumes you’re writing code the old-fashioned way by using manual compilation from the command-line. No need to do that – when they tell you to compile and run an exercise, just run the project on NetBeans. You can do all the exercises from the safety of NetBeans.
Goodbye
Thanks for your interest, and good luck with Java! I’m no Java expert but if you have questions feel free to comment on this post, email me, ಅಥವಾ ask me on Twitter.