SlideShare a Scribd company logo
This section explains how to use the PATH and CLASSPATH environment variables on Microsoft
Windows, Solaris, and Linux. Consult the installation instructions included with your installation
of the Java Development Kit (JDK) software bundle for current information.
After installing the software, the JDK directory will have the structure shown below.
The bin directory contains both the compiler and the launcher.

Update the PATH Environment Variable (Microsoft
Windows)
You can run Java applications just fine without setting the PATH environment variable. Or, you
can optionally set it as a convenience.
Set the PATH environment variable if you want to be able to conveniently run the executables
(javac.exe, java.exe, javadoc.exe, and so on) from any directory without having to type
the full path of the command. If you do not set the PATH variable, you need to specify the full
path to the executable every time you run it, such as:
C:Javajdk1.7.0binjavac MyClass.java

The PATH environment variable is a series of directories separated by semicolons (;).
Microsoft Windows looks for programs in the PATH directories in order, from left to right. You
should have only one bin directory for the JDK in the path at a time (those following the first
are ignored), so if one is already present, you can update that particular entry.
The following is an example of a PATH environment variable:
C:Javajdk1.7.0bin;C:WindowsSystem32;C:Windows;C:WindowsSystem32Wbem

It is useful to set the PATH environment variable permanently so it will persist after rebooting.
To make a permanent change to the PATH variable, use the System icon in the Control Panel.
The precise procedure varies depending on the version of Windows:
Windows XP
1. Select Start, select Control Panel. double click System, and select the Advanced tab.
2. Click Environment Variables. In the section System Variables, find the PATH
environment variable and select it. Click Edit. If the PATH environment variable does not
exist, click New.
3. In the Edit System Variable (or New System Variable) window, specify the value of the
PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows Vista:
1. From the desktop, right click the My Computer icon.
2. Choose Properties from the context menu.
3. Click the Advanced tab (Advanced system settings link in Vista).
4. Click Environment Variables. In the section System Variables, find the PATH
environment variable and select it. Click Edit. If the PATH environment variable does not
exist, click New.
5. In the Edit System Variable (or New System Variable) window, specify the value of the
PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows 7:
1. From the desktop, right click the Computer icon.
2. Choose Properties from the context menu.
3. Click the Advanced system settings link.
4. Click Environment Variables. In the section System Variables, find the PATH
environment variable and select it. Click Edit. If the PATH environment variable does not
exist, click New.
5. In the Edit System Variable (or New System Variable) window, specify the value of the
PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Note: You may see a PATH environment variable similar to the following when editing it from
the Control Panel:
%JAVA_HOME%bin;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem

Variables enclosed in percentage signs (%) are existing environment variables. If one of these
variables is listed in the Environment Variables window from the Control Panel (such as
JAVA_HOME), then you can edit its value. If it does not appear, then it is a special environment

variable that the operating system has defined. For example, SystemRoot is the location of
the Microsoft Windows system folder. To obtain the value of a environment variable, enter the
following at a command prompt. (This example obtains the value of the SystemRoot
environment variable):
echo %SystemRoot%
Update the PATH Variable (Solaris and Linux)
You can run the JDK just fine without setting the PATH variable, or you can optionally set it as
a convenience. However, you should set the path variable if you want to be able to run the
executables (javac, java, javadoc, and so on) from any directory without having to type the
full path of the command. If you do not set the PATH variable, you need to specify the full path
to the executable every time you run it, such as:
% /usr/local/jdk1.7.0/bin/javac MyClass.java

To find out if the path is properly set, execute:
% java -version

This will print the version of the java tool, if it can find it. If the version is old or you get the
error java: Command not found, then the path is not properly set.
To set the path permanently, set the path in your startup file.
For C shell (csh), edit the startup file (~/.cshrc):
set path=(/usr/local/jdk1.7.0/bin )

For bash, edit the startup file (~/.bashrc):
PATH=/usr/local/jdk1.7.0/bin:
export PATH

For ksh, the startup file is named by the environment variable, ENV. To set the path:
PATH=/usr/local/jdk1.7.0/bin:
export PATH

For sh, edit the profile file (~/.profile):
PATH=/usr/local/jdk1.7.0/bin:
export PATH

Then load the startup file and verify that the path is set by repeating the java command:
For C shell (csh):
% source ~/.cshrc
% java -version

For ksh, bash, or sh:
% . /.profile
% java -version

Checking the CLASSPATH variable (All platforms)
The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look
for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be
defined through other means, such as the bootstrap class path or the extensions directory.)
The preferred way to specify the class path is by using the -cp command line switch. This
allows the CLASSPATH to be set individually for each application without affecting other
applications. Setting the CLASSPATH can be tricky and should be performed with care.
The default value of the class path is ".", meaning that only the current directory is searched.
Specifying either the CLASSPATH variable or the -cp command line switch overrides this
value.
To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the following:
C:> echo %CLASSPATH%

On Solaris or Linux, execute the following:
% echo $CLASSPATH

If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux)
or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).
To modify the CLASSPATH, use the same procedure you used for the PATH variable.
Class path wildcards allow you to include an entire directory of .jar files in the class path
without explicitly naming them individually. For more information, including an explanation of
class path wildcards, and a detailed description on how to clean up the CLASSPATH
environment variable, see the Setting the Class Path [1] technical note.
1. http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

More Related Content

RTF
Trigger and cursor program using sql
Sushil Mishra
 
PPTX
Cursors, triggers, procedures
Vaibhav Kathuria
 
PDF
Dynamic websites lec3
Belal Arfa
 
PPTX
Oracle: Cursors
DataminingTools Inc
 
PPTX
Database Systems - SQL - DCL Statements (Chapter 3/4)
Vidyasagar Mundroy
 
PPTX
ORACLE PL SQL FOR BEGINNERS
mohdoracle
 
PPTX
Java class 8
Edureka!
 
Trigger and cursor program using sql
Sushil Mishra
 
Cursors, triggers, procedures
Vaibhav Kathuria
 
Dynamic websites lec3
Belal Arfa
 
Oracle: Cursors
DataminingTools Inc
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Vidyasagar Mundroy
 
ORACLE PL SQL FOR BEGINNERS
mohdoracle
 
Java class 8
Edureka!
 

What's hot (19)

PPT
Basic cursors in oracle
Suhel Firdus
 
PDF
SSAdaP 1989 DECUS Europe Symposium Jan Holy
Jan Holy
 
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PPTX
PLSQL Tutorial
Quang Minh Đoàn
 
PPTX
Jasper Report - Lesson
Alex Fernandez
 
ODP
My sql Syntax
Reka
 
PPTX
Oracle: PLSQL Introduction
DataminingTools Inc
 
PPT
Db Triggers05ch
theo_10
 
PPTX
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
PDF
Database Systems - SQL - DDL Statements (Chapter 3/3)
Vidyasagar Mundroy
 
PPTX
Plsql guide 2
Vinay Kumar
 
TXT
Sql procedures
Gaurish Goel
 
PPT
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
InSync Conference
 
PPT
PLSQL Cursors
spin_naresh
 
ODP
My sql
Nadhi ya
 
PPT
Sql dml & tcl 2
Dr. C.V. Suresh Babu
 
PPTX
Oracle: DDL
DataminingTools Inc
 
PPT
Review of SQL
Information Technology
 
Basic cursors in oracle
Suhel Firdus
 
SSAdaP 1989 DECUS Europe Symposium Jan Holy
Jan Holy
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PLSQL Tutorial
Quang Minh Đoàn
 
Jasper Report - Lesson
Alex Fernandez
 
My sql Syntax
Reka
 
Oracle: PLSQL Introduction
DataminingTools Inc
 
Db Triggers05ch
theo_10
 
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
Database Systems - SQL - DDL Statements (Chapter 3/3)
Vidyasagar Mundroy
 
Plsql guide 2
Vinay Kumar
 
Sql procedures
Gaurish Goel
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
InSync Conference
 
PLSQL Cursors
spin_naresh
 
My sql
Nadhi ya
 
Sql dml & tcl 2
Dr. C.V. Suresh Babu
 
Oracle: DDL
DataminingTools Inc
 
Review of SQL
Information Technology
 
Ad

Viewers also liked (7)

PDF
Your first-java-program
Louis Slabbert
 
ODP
Cirrostratus
Stanislav Bogatyrev
 
PDF
How to Install java JRE and JDK - STEP 1
Louis Slabbert
 
PDF
How-to-Setup-j-creator-for-JAVA-programming
Louis Slabbert
 
PPTX
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
Louis Slabbert
 
PPTX
Curriculum Power Point
guest74dd4f
 
PPSX
How to Optimise your website with SEO - Simple SEO guide updated for 2014
Louis Slabbert
 
Your first-java-program
Louis Slabbert
 
Cirrostratus
Stanislav Bogatyrev
 
How to Install java JRE and JDK - STEP 1
Louis Slabbert
 
How-to-Setup-j-creator-for-JAVA-programming
Louis Slabbert
 
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
Louis Slabbert
 
Curriculum Power Point
guest74dd4f
 
How to Optimise your website with SEO - Simple SEO guide updated for 2014
Louis Slabbert
 
Ad

Similar to Setup Java Path and classpath (from the java™ tutorials essential classes - the platform environment) (20)

PPTX
java:characteristics, classpath, compliation
Shivam Singhal
 
PDF
Java part 1
ACCESS Health Digital
 
PDF
Java Configuration on Windows Xp
Abdinav Kumar Singh
 
PDF
Java 17 Recipes - A problem-solution approach 4th Edition Josh Juneau
semsirorjeta27
 
PDF
Introduction to java
Rakesh Singh
 
PDF
Setting home path class path and path for java on windows 7
Ravi Kumar Lanke
 
PPTX
Classpath
myrajendra
 
PPTX
How to install Java and how to set the path
yesheeka
 
PPTX
Jdk installation
Weei-Jye Chay
 
PDF
Java 17 Recipes A Problemsolution Approach Josh Juneau Luciano Manelli
fufahkuhaa
 
PPTX
Installation of java and program execution
Rakhee Chhibber
 
PDF
Java 17 Recipes - A problem-solution approach 4th Edition Josh Juneau
yfniusvx286
 
PDF
4 implementing java program cinouke abd execye..pdf
SATYA136395
 
PDF
Automation framework using selenium webdriver with java
Narayanan Palani
 
PPT
Oop lecture4
Shahriar Robbani
 
PPTX
HOW TO SET PATH IN JAVA
Rhythm Suiwal
 
PPT
Training Java - Lesson1
mittoq
 
PPTX
chap 10 : Development (scjp/ocjp)
It Academy
 
PPT
0_A1590026209_21789_20_2018_0 Lecture.ppt
RithwikRanjan
 
java:characteristics, classpath, compliation
Shivam Singhal
 
Java Configuration on Windows Xp
Abdinav Kumar Singh
 
Java 17 Recipes - A problem-solution approach 4th Edition Josh Juneau
semsirorjeta27
 
Introduction to java
Rakesh Singh
 
Setting home path class path and path for java on windows 7
Ravi Kumar Lanke
 
Classpath
myrajendra
 
How to install Java and how to set the path
yesheeka
 
Jdk installation
Weei-Jye Chay
 
Java 17 Recipes A Problemsolution Approach Josh Juneau Luciano Manelli
fufahkuhaa
 
Installation of java and program execution
Rakhee Chhibber
 
Java 17 Recipes - A problem-solution approach 4th Edition Josh Juneau
yfniusvx286
 
4 implementing java program cinouke abd execye..pdf
SATYA136395
 
Automation framework using selenium webdriver with java
Narayanan Palani
 
Oop lecture4
Shahriar Robbani
 
HOW TO SET PATH IN JAVA
Rhythm Suiwal
 
Training Java - Lesson1
mittoq
 
chap 10 : Development (scjp/ocjp)
It Academy
 
0_A1590026209_21789_20_2018_0 Lecture.ppt
RithwikRanjan
 

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Software Development Company | KodekX
KodekX
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 

Setup Java Path and classpath (from the java™ tutorials essential classes - the platform environment)

  • 1. This section explains how to use the PATH and CLASSPATH environment variables on Microsoft Windows, Solaris, and Linux. Consult the installation instructions included with your installation of the Java Development Kit (JDK) software bundle for current information. After installing the software, the JDK directory will have the structure shown below. The bin directory contains both the compiler and the launcher. Update the PATH Environment Variable (Microsoft Windows) You can run Java applications just fine without setting the PATH environment variable. Or, you can optionally set it as a convenience. Set the PATH environment variable if you want to be able to conveniently run the executables (javac.exe, java.exe, javadoc.exe, and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as: C:Javajdk1.7.0binjavac MyClass.java The PATH environment variable is a series of directories separated by semicolons (;). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should have only one bin directory for the JDK in the path at a time (those following the first are ignored), so if one is already present, you can update that particular entry. The following is an example of a PATH environment variable: C:Javajdk1.7.0bin;C:WindowsSystem32;C:Windows;C:WindowsSystem32Wbem It is useful to set the PATH environment variable permanently so it will persist after rebooting. To make a permanent change to the PATH variable, use the System icon in the Control Panel. The precise procedure varies depending on the version of Windows: Windows XP
  • 2. 1. Select Start, select Control Panel. double click System, and select the Advanced tab. 2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New. 3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Windows Vista: 1. From the desktop, right click the My Computer icon. 2. Choose Properties from the context menu. 3. Click the Advanced tab (Advanced system settings link in Vista). 4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New. 5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Windows 7: 1. From the desktop, right click the Computer icon. 2. Choose Properties from the context menu. 3. Click the Advanced system settings link. 4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New. 5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Note: You may see a PATH environment variable similar to the following when editing it from the Control Panel: %JAVA_HOME%bin;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem Variables enclosed in percentage signs (%) are existing environment variables. If one of these variables is listed in the Environment Variables window from the Control Panel (such as JAVA_HOME), then you can edit its value. If it does not appear, then it is a special environment variable that the operating system has defined. For example, SystemRoot is the location of the Microsoft Windows system folder. To obtain the value of a environment variable, enter the following at a command prompt. (This example obtains the value of the SystemRoot environment variable): echo %SystemRoot%
  • 3. Update the PATH Variable (Solaris and Linux) You can run the JDK just fine without setting the PATH variable, or you can optionally set it as a convenience. However, you should set the path variable if you want to be able to run the executables (javac, java, javadoc, and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as: % /usr/local/jdk1.7.0/bin/javac MyClass.java To find out if the path is properly set, execute: % java -version This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set. To set the path permanently, set the path in your startup file. For C shell (csh), edit the startup file (~/.cshrc): set path=(/usr/local/jdk1.7.0/bin ) For bash, edit the startup file (~/.bashrc): PATH=/usr/local/jdk1.7.0/bin: export PATH For ksh, the startup file is named by the environment variable, ENV. To set the path: PATH=/usr/local/jdk1.7.0/bin: export PATH For sh, edit the profile file (~/.profile): PATH=/usr/local/jdk1.7.0/bin: export PATH Then load the startup file and verify that the path is set by repeating the java command:
  • 4. For C shell (csh): % source ~/.cshrc % java -version For ksh, bash, or sh: % . /.profile % java -version Checking the CLASSPATH variable (All platforms) The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class path or the extensions directory.) The preferred way to specify the class path is by using the -cp command line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications. Setting the CLASSPATH can be tricky and should be performed with care. The default value of the class path is ".", meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value. To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the following: C:> echo %CLASSPATH% On Solaris or Linux, execute the following: % echo $CLASSPATH If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP). To modify the CLASSPATH, use the same procedure you used for the PATH variable. Class path wildcards allow you to include an entire directory of .jar files in the class path without explicitly naming them individually. For more information, including an explanation of
  • 5. class path wildcards, and a detailed description on how to clean up the CLASSPATH environment variable, see the Setting the Class Path [1] technical note. 1. http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html