SlideShare a Scribd company logo
1 of 5
Download to read offline
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

What's hot (20)

Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
 
SSAdaP 1989 DECUS Europe Symposium Jan Holy
SSAdaP 1989 DECUS Europe Symposium Jan HolySSAdaP 1989 DECUS Europe Symposium Jan Holy
SSAdaP 1989 DECUS Europe Symposium Jan Holy
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Jasper Report - Lesson
Jasper Report - LessonJasper Report - Lesson
Jasper Report - Lesson
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Db Triggers05ch
Db Triggers05chDb Triggers05ch
Db Triggers05ch
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)
 
Plsql guide 2
Plsql guide 2Plsql guide 2
Plsql guide 2
 
Sql procedures
Sql proceduresSql procedures
Sql procedures
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
My sql
My sqlMy sql
My sql
 
Oracle - Program with PL/SQL - Lession 18
Oracle - Program with PL/SQL - Lession 18Oracle - Program with PL/SQL - Lession 18
Oracle - Program with PL/SQL - Lession 18
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
Review of SQL
Review of SQLReview of SQL
Review of SQL
 

Viewers also liked

Your first-java-program
Your first-java-programYour first-java-program
Your first-java-programLouis Slabbert
 
How to Install java JRE and JDK - STEP 1
How to Install java JRE and JDK - STEP 1How to Install java JRE and JDK - STEP 1
How to Install java JRE and JDK - STEP 1Louis Slabbert
 
How-to-Setup-j-creator-for-JAVA-programming
How-to-Setup-j-creator-for-JAVA-programmingHow-to-Setup-j-creator-for-JAVA-programming
How-to-Setup-j-creator-for-JAVA-programmingLouis Slabbert
 
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]Louis Slabbert
 
Curriculum Power Point
Curriculum Power PointCurriculum Power Point
Curriculum Power Pointguest74dd4f
 
How to Optimise your website with SEO - Simple SEO guide updated for 2014
How to Optimise your website with SEO - Simple SEO guide updated for 2014How to Optimise your website with SEO - Simple SEO guide updated for 2014
How to Optimise your website with SEO - Simple SEO guide updated for 2014Louis Slabbert
 

Viewers also liked (7)

Your first-java-program
Your first-java-programYour first-java-program
Your first-java-program
 
Cirrostratus
CirrostratusCirrostratus
Cirrostratus
 
How to Install java JRE and JDK - STEP 1
How to Install java JRE and JDK - STEP 1How to Install java JRE and JDK - STEP 1
How to Install java JRE and JDK - STEP 1
 
How-to-Setup-j-creator-for-JAVA-programming
How-to-Setup-j-creator-for-JAVA-programmingHow-to-Setup-j-creator-for-JAVA-programming
How-to-Setup-j-creator-for-JAVA-programming
 
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
Chris Brown - Beautiful People ft. Benny Benassi + [Lyrics On Screen]
 
Curriculum Power Point
Curriculum Power PointCurriculum Power Point
Curriculum Power Point
 
How to Optimise your website with SEO - Simple SEO guide updated for 2014
How to Optimise your website with SEO - Simple SEO guide updated for 2014How to Optimise your website with SEO - Simple SEO guide updated for 2014
How to Optimise your website with SEO - Simple SEO guide updated for 2014
 

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

java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliationShivam Singhal
 
You can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commenYou can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commenanitramcroberts
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 stepsIshara Amarasekera
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMmanish kumar
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction AKR Education
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
Automation framework using selenium webdriver with java
Automation framework using selenium webdriver with javaAutomation framework using selenium webdriver with java
Automation framework using selenium webdriver with javaNarayanan Palani
 
Installing Python on Windows OS
Installing Python on Windows OSInstalling Python on Windows OS
Installing Python on Windows OSWei-Wen Hsu
 
Installing d space on windows
Installing d space on windowsInstalling d space on windows
Installing d space on windowsBibliounivbtn
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for DesignersR. Sosa
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 

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

java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliation
 
Dspace
DspaceDspace
Dspace
 
JAVA_STEP_V7
JAVA_STEP_V7JAVA_STEP_V7
JAVA_STEP_V7
 
You can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commenYou can look at the Java programs in the text book to see how commen
You can look at the Java programs in the text book to see how commen
 
Env
EnvEnv
Env
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 steps
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
Java Quiz - Meetup
Java Quiz - MeetupJava Quiz - Meetup
Java Quiz - Meetup
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Automation framework using selenium webdriver with java
Automation framework using selenium webdriver with javaAutomation framework using selenium webdriver with java
Automation framework using selenium webdriver with java
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
 
Installing Python on Windows OS
Installing Python on Windows OSInstalling Python on Windows OS
Installing Python on Windows OS
 
Understanding Annotations in Java
Understanding Annotations in JavaUnderstanding Annotations in Java
Understanding Annotations in Java
 
Installing d space on windows
Installing d space on windowsInstalling d space on windows
Installing d space on windows
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
SQL2SPARQL
SQL2SPARQLSQL2SPARQL
SQL2SPARQL
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 

Recently uploaded

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

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