Become a Java Programmer

To become a Java programmer, you need a "compiler", a program to convert Java source code to bytecode. In the old days, the only option was Oracle's Java Development Kit; but now you have many options, including the GNU project's gcj which creates class files or native executables, and jikes, IBM's open source contribution. You also will need a Java virtual machine, which is a "machine within a machine" which understands Java bytecodes and translates them into machine language on the target processor. There are many available, but you can never go wrong with the javac compiler and java JRE virtual machine included with Oracle's Java standard edition.

Steps

  1. Visit Oracle's Java SE download page and download the correct package for your platform: typically Windows, Linux, or Solaris. Macintosh users will find they already have the J2SE installed. Alternatively, use an open-source or other third-party compiler such as gcj or jikes, and compile to a native executable or run it with the Java JRE.
  2. Learn to use a basic, "clean" editor like Notepad (Windows), vim or Emacs or Notepad++ (Windows) or Sublime Text or Gedit (Linux). These don't taint your program source with formatting information as does, for example, Microsoft Word or Libreoffice Write. Whatever editor you use must have the option to save as "plain text".
  3. Learn the basic edit-compile-test cycle (or build cycle):
    1. Create or edit the program source file(s).
    2. Compile to .class files.
    3. Run the program with the Java executable, or as an applet in a browser. If the functionality isn't correct, or you want to add more features, start again at step 1.
  4. Compile and run a simple Hello World! application to get familiar with the process.
  5. When you run into a snag, a large number of problems and their solutions can be found with a search engine, like Yahoo! and Google. Make good use of this extraordinary resource.

Tips

  • Unnecessarily long methods (the Java name for subroutines) are looked down upon since they make your code hard to read and difficult to update; learn to factor your code into small, precise modules that do one thing well.
  • Keep your code organized, and add plenty of comments for easy reading, remembering, and updating. Remember that code is read more often, that it is written.
  • After you master the basics, start a programming project that means something to you, or join an existing open source project and work together with other people.
  • Don't use "magic numbers": numbers and values that are distributed through your code when they should be defined as a constant, e. g.:
    static final int HTTP_PORT = 80; // server port for HTTP (web) service
    This way they can be reused, and explained in a comment so what they represent can be understood; making your code easier to maintain and update.
  • For specific info on the classes, methods, and variables, visit Oracle's API documentation. It might also be a good idea to download it to your hard drive in case you lose Internet connectivity (Look for Java SE Documentation and click the download button).
  • Optionally, download and install an IDE (Integrated Development Environment). For example: NetBeans (open source) or Eclipse (open source) or Intellij Idea. This will help speed up the edit-compile-test cycle, at the expense of extra overhead like having to learn a new tool. Another option is a text-based tool such as Apache Maven (open source) or Apache Ant (open source) or Gradle (open source), which gives you full control over the process (Note that some of the above mentioned IDE's also support these tools).
  • Buy a basic book on Java programming. One can often find older editions for a very low price at thrift shops, library used book sales, and online auctions or booksellers. Though the online API docs, articles, and troubleshooting tips are usually available to you, a book is often more convenient, and can be perused while commuting by bus, sitting in a bar or coffee shop, and for a little light reading before going to sleep.
  • Read and Follow the Oracle's Java tutorial, that will teach you the basics of Java, while also allowing you to go deeper in the language.

Things You'll Need

Related Articles

Sources and Citations