Java Article 5 - Java and Editors

Fix link appearance

In this article we will cover the basics of the Java Virtual Machine and what software you need to start writing Java programs of your own. One great thing about Java is you can get everything needed to program and run Java programs for free.

Java programs, like C#/.net, run in a managed environment. For Java this is called the Java Virtual Machine (JVM). A virtual machine is a program suite that runs in memory and acts as a computer, following instructions provided to it by a program. JVM runs .class and .jar files.

You probably know that a traditional .exe file is simply run by your computer when you click on it in a file explorer or click on a shortcut. Well, Java files are actually run by JVM which is, in turn, run by your computer. The neat thing about virtual machines is that they create a very controlled environment for your program to run in. Because of this level of control you can run the same Java file on just about any version of Windows, on Linux or on a Mac. Also the way the program appears and behaves will be the same on any of these machines.

Prior to this, often you would write a program in a language such as C++ and it would run fine on your computer, but when you ran it on some other computer (with the same version of windows even, for example) it would not look the same, and it might even behave differently. This was a real development and testing nightmare that virtual machines eliminated. The downside to virtual machines is that they can be slower since your computer has to go though more steps to get something done due to the presence of the virtual machine acting as a middle-man.

The speeds of different languages can be compared in a lot of different ways, and people argue endlessly about Java and C# being slower than something like C++. The takeaway is that Java is a little slower, however considers these advatages:

  • Computers are getting so fast this speed difference maters less and less.
  • This speed difference typically is not really noticeable unless you are dealing with huge calculations such as in 3-D games. (This is one reason why Java is not typically used for game programming).
  • Many developers believe the slight performance hit is made up for by Java's advantages in its universal compatibility and speed of development since your code does not have to be configured as much (if at all) to run on different machines.

Anyway, on to talking about what you need to write some Java programs.

You need two things:

  • Java (JVM): This is available from Oracle: http://www.java.com Note: Install Java before you install your editor or IDE or you may have problems.
  • An editor or Integrated Development Environment(IDE): to write the program (this acts like a word processor but for Java).

You have some choices when it comes to Editors / IDEs.

Editors are much simpler and have fewer features. IDEs are more complex and have more features. People disagree on which is better. If you consider yourself software savvy and can pick up and use new programs easily I would recommend an IDE. If not go with a simple editor.

There are many out there but two widely used ones are:

Eclipse, a popular free IDE: eclipse.org

jEdit, a popular free editor: jedit.org

So, download and install Java then download and install your editor / IDE. Eclipse comes with its own Hello World tutorial to familiarize yourself with Eclipse and you can write the program we went over in previous articles.

If you are having any trouble, Oracle also has a new user help center and they can walk you though getting set-up and started: oracle.com

In the next article we will look more closely at methods and write and run a simple program.