Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PATH and CLASSPATH

 
kiran vydhyam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a huge confusion between these two terms,atlast I had to post it here.
Please explain me what are it's actual uses,what is the difference between them,and how should I set it and where should I set it.

I encountered this problem when I was trying to enable the assertions in the package level,and it was not able to find my classes.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

PATH is an environment variable used by several different operating systems (both Windows and UNIX) to find program files (*.EXE files.) It always consists of a list of directories. If you type, say, WINWORD.EXE, the OS looks in each directory named on the PATH to find this program file.

Note that PATH has nothing to do with Java, except that the OS will use the PATH to find JAVA.EXE and JAVAC.EXE, etc.

CLASSPATH is an environment variable used by Java (and only by Java) to find .class files. It is a list of directories and/or .jar files that contain classes. When Java needs to load a class, it will look in all the locations named by the CLASSPATH.

Note that the OS has absolutely no use for CLASSPATH and couldn't care less what you've set it to (or not.)

You might be interested in the JavaRanch FAQ on How to set the classpath.
 
kiran vydhyam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou so much.It was so nicely explained.I will never be confused about these two terms till my last breath.

Thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic