K.I.S.S Java Example

This HowTo assumes you already have the JDK - Java Development Kit installed and configured in your system so you can use the javac (Java Compiler) command using your prompt. Also, this is a simple example of a Main class/method and a little code, a "HELLO WORLD!" per say. If you don't know, every Java executable must have a main method.

STEP 1
Create a text file named Kiss.java with your text editor. This will be your source code.
Oh. Everything here is case sensitive.

STEP 2
Let's make the code! Start typing right into the file Kiss.java you just have created:

class Kiss
{
   public static void main(String args[])
   {
      //This will print the meaning of K.I.S.S
      System.out.println("K.I.S.S - Keep It Simple and Short");
   }
}

STEP 3
Now, let's make this baby talk. Open your command prompt or shell or terminal (whatever), go to the location where you saved you Kiss.java file. 
Type: javac Kiss.java
If your code is okay, it will be compiled and a new file will be created: The Kiss.class - this is your code compiled to Java Bytecode. Now we just need to run:
Type: java Kiss
Your console will print:
K.I.S.S - Keep It Simple and Short

Congratulations! Now you have done your perfect Java code and can start to expand your horizons.

Comments

  1. Please visit www.oracle.com to download the JDK or...install the NetBeans IDE, it will do the work for you. :p

    ReplyDelete

Post a Comment

Please leave your comment! It will always be interesting!

Popular Posts

SPONSORS

Methark - Business, Marketing & IT Outsourcing

LinkCollider - Website Ranking Tool Using Social Media