Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

How to set the command path

JavaFAQ Home » Murachs Java SE6 book Go to all tips in Murachs Java SE6 book


Bookmark and Share

How to set the command path

Figure 1-6 shows you how to configure Windows to make it easier to work with the JDK. If you're not using Windows, you can refer to the Java web site to see what you need to do to configure Java for your system.

To configure Windows to work with the JDK, you need to add the bin directory to the command path. That way, Windows will know where to look to find the Java commands that you use.

If you're using Windows 2000, NT, or XP, you can use the first procedure in this figure to set the command path. To start, you display the System Properties dialog box. One easy way to do that is to press the Windows key and the Pause / Break key at the same time. Then, you select the Advanced tab of this dialog box, and select the Environment Variables button. Finally, you use the Environment Variables dialog box to edit the system variable named Path.

When you find the system variable named Path in the Environment Variables dialog box, you can usually add the path for the Java bin directory to the end of the list of paths. To do that, you type a semicolon and the complete path (shaded at the top of this figure). However, if you've installed previous versions of Java on your system, you need to make sure that the path for JDK 1.6 is in front of the path for earlier versions.

If you're using Vista, you still use the Environment Variables dialog box to edit the system variable named Path. However, due to increased security, the procedure for displaying this dialog box is more elaborate when you're using Vista. To start, you can press the Windows key and the Pause / Break key at the same time to display the System section of the Control Panel. Then, you can select the Advanced System Settings link. When you do, Vista will prompt you with a User Account Control dialog box. If your user account has administrative permissions, you can proceed by selecting the Continue button. If not, you will be required to enter a password for one of the administrator accounts for the computer before you can continue. Either way, selecting the Continue button in this dialog box temporarily elevates your permissions to an administrator account when you change the Path variable and lowers your permissions to a normal user account after you're done.

Whenever you edit the command path, be careful! Since the command path may affect the operation of other programs on your PC, you don't want to delete or modify any of the other paths. You only want to add one directory to the command path. If that doesn't work, be sure that you're able to restore the command path to its original condition.

If you don't configure Windows in this way, you can still compile and run Java programs, but it's more difficult. For instance, instead of typing a command like this to compile a Java class

javac

you may need to type this command:

\Program Files\Java\jdk1.6.0\bin\javac

As you can see, then, setting the command path makes this much simpler. That's why it's so important to get this set right.

typical Path variable

%SystemRoot%;%SystemRoot%\system32;C:\Program Files\Java\jdk1.6.0\bin;

How to set the path for Windows 2000/NT/XP

1. Display the System Properties dialog box. To do that, press the Windows key and the Pause / Break key at the same time. Or, right-click on the My Computer icon that's available from the desktop or the Start menu and select the Properties command.

2. In the System Properties dialog box, select the Advanced tab and click on the Environment Variables button.

3. Use the Environment Variables dialog box to edit the system variable named Path. If you haven't installed earlier versions of Java, type a semicolon and the path for the bin subdirectory of JDK 1.6 to the far right of the list of paths. Otherwise, add the 1.6 path followed by a semicolon before the paths for earlier JDK versions.

How to set the path for Windows Vista

1. Display the System section of the Control Panel. To do that, display the Control Panel, select the System and Maintenance link, and select the System link. Or, press the Windows key and the Pause / Break key at the same time.

2. Select the Advanced System Settings link. When you do, Vista will prompt you with a User Account Control dialog box.

3. In the User Account Control dialog box, proceed by selecting the Continue button. If necessary, enter the password for an administrator account before selecting the Continue button.

4. Follow steps 2 and 3 from the Windows 2000/NT/XP procedure shown above.

How to check the current path

  • Start a Command Prompt or DOS Prompt as described in figure 1-12. Then, enter the Path command by typing the word path. This will display the current path statement.

Description

  • The command path on a Windows system tells Windows where to look for the com-
    mands that it is told to execute. When you use Java tools, you need to add the path for
    the jdk1.6.0\bin directory that's shown above.

Notes

  • For more information about setting the path for Windows or for information about
    configuring non-Windows operating systems, you can refer to the Java web site.

Introduction to Java ...................................................................... 4
Toolkits and platforms ....................................................................... 4
Java compared to C++ ...................................................................... 4
Java compared to C# ........................................................................ 4
Applications, applets, and servlets ....................................................... 6
How Java compiles and interprets code ................................................ 8
How to prepare your system for using Java .................................. 10
How to install the JDK ..........................................................................10
A summary of the directories and files of the JDK ...................................12
How to set the command path ...............................................................14
How to set the class path ..................................................................... 16
How to use TextPad to work with Java ........................................... 18
How to install TextPad ......................................................................... 18
How to use TextPad to save and edit source code ................................... 20
How to use TextPad to compile source code ........................................... 22
How to use TextPad to run an application ............................................... 22
Common error messages and solutions ................................................. 24
How to use the command prompt to work with Java ...................... 26
How to compile source code ................................................................. 26
How to run an application ..................................................................... 26
How to compile source code with a switch .............................................. 28
Essential DOS skills for working with Java ............................................. 30
How to use the documentation for the Java SE API ....................... 32
How to install the API documentation ..................................................... 32
How to navigate the API documentation ................................................. 34
Introduction to Java IDEs ................................................................ 36
The Eclipse IDE for Java ....................................................................... 36
The NetBeans IDE ................................................................................ 38
The BlueJ IDE ...................................................................................... 38
Perspective ....................................................................................... 40

The chapter 1 of Murach's Java SE 6 excellent book (it is a MUST for all newbees!) is published on our site with written permission of the copyright owner. It was slightly adapted to our site layout. If you want to take a look at PDF version please follow the link here.

 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy