Friday, September 20, 2013

Programing with Java using Command Prompt







Step 1: Download latest JDK

               1.Follow this link: http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Click Download JDK under the download Java Standard Edition panel.
3. Choose your operating System and agree to the terms of service. **
** This will  probably be Windows since your using Command Prompt.

Step 2: Setting Path for Command Prompt

1. Open the Command Prompt .
2 Type "set Path=C:\Program Files\Java\jdk1.6.0_21\bin" .*
3. Type  " set HomePath= C:\Program Files\Java\ jdk1.6.0_21 *

* If you have a later jdk ( i.e. jdk 1.6.0_22) replace the portion that says jdk1.6.0_21 with it.

** If you don't know which jdk you have go to: start pane( at bottom left corner of you screen)>click run> click browse>Then  go to C:\Program Files\Java

*** Do not type quotation marks in steps 1-3  at command prompt.

Step 3: Creating a Simple Java Program

Create Program
1. Go to Start pane>All Programs > Accessories> Notepad.exe
2 Copy and paste the following exactly:
public class helloworld
{
public static void main(String[] args)
{

System.out.println("Hello World!");

}
}
3. a.Save file as: helloworld.java
     b.Make sure "save as type" under where you typed the file name as "All Files" (as opposed to the default "Text-File").
      c. You want to save your java file where  the Command Prompt  is set to open at.*

*Such as C:\Users\MyUserName

Step 4: Compiling and Executing the Program

          1.First compile file by going to Command Prompt and typing javac  helloworld.java
2.This will create a class file which you can execute by typing java helloworld
3. It should print "Hello World!" to show your done.

Step 5: Learn More

             1. The next thing you want to do is get a textbook that will teach you the Java language, precisely.I recommend Programing and Problem Solving with Java
 by Nell B. Dale and  Chip Weems .
2. You can get this from Amazon.com following this link:
http://www.amazon.com/Programming-Problem-Solving-Java-Weems/dp/0763734020/ref=sr_1_2?ie=UTF8&qid=1291909285&sr=8-2

1 comment:


  1. Thank you for sharing the excellent post about JAVA programming. you helped me to gain more information on the JAVA language.
    JAVA J2EE Training in Chennai
    JAVA J2EE Training Institutes in Chennai

    ReplyDelete