Wednesday, April 30, 2014

HELLO WORLD!! - Java

I decided to do a Hello World blog whenever I want to learn or work on a programming language. These are notes for myself in case I lose interest and want to come back to a language. Today, I do Java!.

1.  Download the latest Java JDK (http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp).  At the time of this writing, it is Java 8.
2.  Install.

I did this in Windows 7 so going forward, this will be Win7 notes.

3.  Change the PATH - Open the Advanced System Settings - Environment Variables - PATH
4.  Add the path of the Java.exe and/or Javac.exe to the Variable Name field.  Don't forget the semicolon.  (ie:  C:\Program Files\Java\jdk.1.8.0_05\bin;)  You might need to add (x86) to the end of "Program Files" if javac gives you a "not recognized as an internal or external command" error (ie:  C:\Program Files(x86)\Java\jdk.1.8.0_05\bin;)
5.  Open Notepad and type:

public class helloworld
{
  public static void main(String[] arg)
  {
    System.out.println("Hello World!");
  }
}

6.  Save as helloworld.java
7.  Type javac helloworld.java in the command prompt to compile.
8.  If no errors you can check to see that helloworld.class is created.
9.  Type java helloworld in the command prompt and you should get....

Hello World!