• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting the classpath  RSS feed

 
Under Taker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys am new to the java world, so might have some questions which might seem pretty silly to most.
Have just downloaded the SDK from sun, after installing it ,how do i set the class path so that i can compile and execute my java files from any folder on my hard drive ?
 
Amit More
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set your classpath as follow:
creat a txt file having :
set classpath=%CLASSPATH%;C:\j2sdk_1.4.0\bin\*;C:\j2sdk_1.4.0\lib\*;
save this file as like StartJava.cmd ( particularly in C folder )
and then before compiling your java code
run this file from command prompt as:
C:>StartJava
It will set your classpath and then you can execute your java codes.
Each time whenever you will lauch a new command prompt you have to execute this StartJava.cmd.
All the best
 
Amit KumarS
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiiii..
there are different ways to permanently set classpaths according to the OS you are using...
if you are using Windows NT/2000 then follow these steps
1. right click on My Computers
2. click on Environment tab
3. select classpath and add the following into it
<drive_letter>:\j2sdk_1.4.0\bin
4. select PATH and append the following string
<drive_letter>:\j2sdk_1.4.0\lib;
and you are done. you will not need to set classpath everytime you open a new window or restart the machine.
in windows98 onwards
you need to append both the above strings into the PATH variable.
and yeah do remember to restart.. sometimes this doesn't work unless you restart machine..
if still in doubt please revert back
Thanks
Amit
 
Under Taker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI amit and amit,
I am using windows XP, i went to the SUN documentation page too, and followed the instructions but that doesnt work either (that is obviously after trying the methods you guys suggested).
I go to the control panel>system>advanced>environment variables>system variables tab and set my classpath, it still doesnt work, any idea why ?
I know i am nearly there, and this is really frustrating.

Undertaker!!
 
Amit KumarS
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi undertaker..
can u please let us know the excat dirctory where u r installing the J2SDK and what classpath are you setting...
then we might be able to find out the bug..
Thanks
Amit
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!