Posts
60
Comments
36
Trackbacks
18
Using Command Prompt with Java

There are several things that I like about using the command prompt with Java.  When beginning to program it can be much less cumbersome than using a integrated development environment (IDE) like Netbeans or Eclipse; where the errors are less descriptive as I will demonstrate here.

To start off, I need to download a Java Development Kit (JDK), and I usually like to use the latest.  In this case it would be Java 6 JDK (at the time of this writing it is update 13, i.e. JDK 6 Update 13).  You can also download the documentation from there as well.  To view the documentation  on the web, you can look here at Java docs.

After selecting my operating system and acknowledging my agreement to their terms, I downloaded and installed JDK 6.  For now I will not register my product, so, with Java installed, I am ready to set up my environment so I can use Java (This example is in Vista 32bit, x86).

1. Click your start button, and roll over Computer and right click.  Select Properties.

5-25-2009 10-41-22 AM

2. Click Advanced Settings

5-25-2009 10-47-10 AM 

3. Select Environment Variables

5-25-2009 10-51-49 AM

4. Find your Path Variable under System Variables, Click Edit.

5-25-2009 1-34-01 PM

5. At the end of the Variable Value, make sure there is a semi colon.  This is where we are going to put the path location of the bin folder of our Java SDK.

5-25-2009 1-37-31 PM

6. Browse to your install location for Java (default is: C:\Program Files\Java\jdk1.6.0_13\bin), making sure you are in the bin folder, click the down arrow in the browser bar.  This will produce the Path variable you need to append in the previous note. Copy the location and go back to your Edit System Variables window(described in 5, above).  (Note: XP Users will need to do the same thing in their ClassPath variable as well)

5-25-2009 1-39-29 PM

7. Make sure you put a semi-colon after your path (to minimize future errors).

5-25-2009 1-45-08 PM

8. Click Ok in Edit System Variables, Ok in Environment Variables, and Ok in System Properties.

9. To test my class path, I go to a command line prompt (Start->Run-> and type cmd, Press Enter).

5-25-2009 1-49-35 PM

10. From your command prompt, type javac test, and press enter.

11. An error like the one below means that it is installed properly.

5-25-2009 1-51-08 PM

 

In this series you learned how to install the Java SDK, Set your Path variable and we also learned how to run a quick test to see if Java has installed properly.  Please leave tips/comments/errors for others to see so that we can make this post a little more comprehensive.  Hope you enjoyed reading.

posted on Monday, May 25, 2009 1:54 PM Print
Comments
Gravatar
# re: Using Command Prompt with Java
Justin
5/27/2009 8:27 PM
  
Thank you for the tutorial. I was beginning to think Windows had no use for a command prompt, other than a token show of appreciation.
Gravatar
# lphccldt
lphccldt
3/17/2010 1:29 PM
  
lphccldt
Gravatar
# nnlrmigh - Google Search
Pingback/TrackBack
3/17/2010 1:29 PM
  
nnlrmigh - Google Search

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 1 and 2 and type the answer here:
News
My Developer Notebook! This also happens to be my opinion place. Thanks for coming by.