Bookmark Topic Watch Topic
  • New Topic

classpath and Path

 
Tusshar Fasate
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Report post to moderator
can anybody tell me details of classpath and path.?
Are they same or any difference is there?


Tushar
SCJP 5.0
 
Matthew Plant
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Report post to moderator
CLASSPATH is where java applications look to find compiled classes (ie. *.class, *.jar)

PATH is where the system looks to find executables (ie. java.exe, javac.exe) so when you type java from the command line, it can find it and you don't have to change to the correct directory first.
 
Tusshar Fasate
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Report post to moderator
How can i set path and classpath?
where to set it?
Does classpath come in to picture at runtime only or it plays any role compile time?
 
Matthew Plant
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Report post to moderator
Under Windows, Goto control panel, system, advanced, environment variables. Path and classpath will probably already be under system variables, you can edit these.

classpath maybe set to "." which means the current directory.

you can also set classpath at runtime when you run java.exe by using the command line switch "-cp [classpath]"

If your project uses external jars, you may need to set this switch when you use javac to compile your classes so javac can located the classes within the jar file.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question multiple times.
 
    Bookmark Topic Watch Topic
  • New Topic