Java Classpath Setting

Google Advertisements

Prev Tutorial Next Tutorial

How to Set Path and Classpath in Java

Setting path and classpath in Java is very simple but before do this process you need to know about path variable and classpath variable. Here I will show you how to set path and classpath in Java in very simple and easy way.

Path Variable

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

Classpath Variable

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.

Video Tutorial

How to Set Path and ClassPath in Java

JDK Folder Hierarchy

JDK folder

Why set path ?

The following programming error is generally for all Java programmers when they compile any Java program.

'javac' is not recognized as an internal or external command, operable program or batch file.

When you get this type of error, then your operating system cannot find the Java compiler (javac). To solve this error you need to set the PATH variable.

Javac is a tool which is available in bin folder so you must set the PATH upto bin folder. In a bin folder all tools are available like javap, javah, jar, javac, java, appletviewer etc. All these tools are used for different-different purpose.

bin folder

set the path and classpath

Go on my computer icon and right click, after that click on properties option.

My computer properties

Now click on advance setting

Advance settings

Click on advance

advance

Click on Advance variables

Environment variable

Click on new button which is below the first box.

Environment variable

Now one dilog box is appear, now ignore this but do not close.

Path and classpath

Now open my computer open c:/ > Programs Files > java > java1.6.0 > bin copy this path

Path and classpath

Now come back on previous open dilogbox and write variable name 'path' and for variable value paste all copied path upto the bin folder. Put .; at the end. It (.) selects all the tools from the bin folder.

Path and classpath

Now open my computer open c:/ > Programs Files > java > java1.6.0 > jre > lib > rt.jar copy this path

Note: rt.jar is available in lib folder this jar files contains all classes of jdk.

Path and classpath

Now again come back on Environment variable dilogbox and click on new. Now one box is open and write path variable as 'classpath' and for variable value paste all copied paths upto rt.jar. Put .; at the end. It (.) selects all the classes from lib folder.

Path and classpath Path and classpath

Note: Finally after set classpath Restart your system, or you can re-open command prompt.


Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on [email protected] or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: [email protected] or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: [email protected] or 8076671483 Try this Keyword C++ Programs