GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes How can i set path and classpath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How can i set path and classpath?" Watch "How can i set path and classpath?" New topic
Author

How can i set path and classpath?

Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
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?
Sanjeev Kulkarni
Greenhorn

Joined: Mar 20, 2006
Posts: 26
Check this out - http://java.sun.com/docs/books/tutorial/java/index.html
Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
sanjiv,be specific..
priya shende
Greenhorn

Joined: Mar 17, 2008
Posts: 20
Hi,
Follow this steps:-
1)Search javac.exe.
2)Then from command prompt go to the directory in which you have saved the program.
3)for example if you found javac.exe in c:\program files\java\jdk1.5.0_12\bin
and you saved java program file in c:\priya> then give following command
c:\priya>set path=%path%;c:\program files\java\jdk1.5.0_12\bin;.;
press enter
4)for classpath give following command
c:\priya>set classpath=%classpath%;c:\program files\java\jdk1.5.0_12\bin;.;
press enter.
Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
thanks priya...
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14194
    
  20

See How To Set The Classpath in the JavaRanch FAQ, and the JDK installation instructions.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11356
    
  16

Originally posted by tushartrue fasate:
sanjiv,be specific..

It would also help if YOU were specific. how you set this does depend on what operating system.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
Originally posted by priya shende:

4)for classpath give following command
c:\priya>set classpath=%classpath%;c:\program files\java\jdk1.5.0_12\bin;.;
press enter.


Disagree. You don't normally need to do anything with the classpath for simple beginner's programs, and you certainly don't want your jdk/bin folder in the classpath.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by fred rosenberger:
... It would also help if YOU were specific. how you set this does depend on what operating system.

Exactly.

It would also help to know why you want to set your classpath, because as Campbell pointed out, this often isn't needed at the beginner stage.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
I think, Marc, this is because you see books with "how to set PATH and CLASSPATH" in, and they don't tell you that the CLASSPATH is usually set up correctly anyway.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

And in the old days (I think it was before Java 1.3), you actually did need to set the classpath for Java to find it's own API classes. Outdated information dies hard.
 
GeeCON Prague 2014
 
subject: How can i set path and classpath?