It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Setting Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting Classpath" Watch "Setting Classpath" New topic
Author

Setting Classpath

chandana kotamraju
Greenhorn

Joined: Jun 14, 2001
Posts: 6
I am new to java.Everytime I am seting the path=c:\jdk1.2.2\bin before compiling.But I am facing problems when I tried to do a swing program.I know that it has something to do with classpath.Can anyone help me by writing in detail how to do it.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Chandana,
You seem to be getting confused with terminology. Your title talks about ClassPath and your topic only mentions Path. There are 2 different paths in question here.
The Path variable you have set seems correct. It is only used in compilation. If your code compiles (with or without errors) then your Path is correct.
The ClassPath variable should at least be set to "." if you plan to run any program from the directory where it resides.
If you are running WinNT:
Goto MyComputer and right click,
Choose properties (last menu item)
Select the Environment Tab
If no CLASSPATH variable exists:
Type in CLASSPATH in the Variable textfield
Type in .; in the Value textfield
If a CLASSPATH does exist:
Make sure it has a single dot(".") in it (between
2 semi-colons).
Click Ok button on bottom of Window.
You should now be able to go to the directory where your *.java file exists, compile it, and run it without any problems.
Regards,
Manfred.
chandana kotamraju
Greenhorn

Joined: Jun 14, 2001
Posts: 6
I am using Win98 . Advice me on seting the class path in Win98.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Chandana,
I don't understand your problem. I am running under Win98 at home and I have never needed to do anything with the class path. You should only have to set it if you have many *.class files that are scattered all around your directories.
When you write basic programs, don't place a package line in it. This will allow you to have all you *.class files in a single directory. Then you just have to CD to that directory and compile and run.
If you are still having problems, you will have better luck explaining what your problem is so if can be fixed. Talking in generalities get us no where ...
Regards,
Manfred.
Tina Parks
Ranch Hand

Joined: Jun 30, 2001
Posts: 35
I had a different take on his question. I thought by his question that he is having trouble configuring his browser to run Swing. No?
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

I am moving this thread to the Beginners forum.
Please continue the discussion there.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
I think you can set your classpath variable in your autoexec.bat file. Once you reboot the system, all the environmental variables will be initialized appropriately.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Setting Classpath
 
Similar Threads
JSTL if-else
Attention !!! Javaranchers . Call For fight against Brian - Dump Posters on the site
SCJP wall of fame
EJB3 testing with JUnit4
implementation class of an interface