| Author |
How to set a class path?
|
Jenny raj
Ranch Hand
Joined: May 19, 2005
Posts: 57
|
|
Dear ranchers could u please help me setting up the class path for my java files? i have just installed JSDK1.5 version.
|
 |
Rick O'Shay
Ranch Hand
Joined: Sep 19, 2004
Posts: 531
|
|
When you compile use javac -classpath ... When you execute use java -classpath ... Do not use the CLASSPATH environment variable. Use a script to compile/run with -classpath.
|
 |
kwame Iwegbue
Ranch Hand
Joined: Sep 02, 2000
Posts: 197
|
|
I'm also a beginner and this is a real bone of contention for me!! my jdk bin files are in c:\program files\java\jdk\bin i usually have to cd down to this dir to javac or java any of my programs. however when i try from C:\> javac -classpath c:\program files\java\jdk\bin MyApp.java java -classpath c:\program files\java\jdk\bin MyApp ...it never works!!! (p.s MyApp.java is not in a named pakage) [ September 27, 2005: Message edited by: kwame Iwegbue ]
|
Who dares, wins! (SAS motto)
|
 |
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
|
|
>..it never works!!! Does it give an error message? What is that message? With the contents of the error message someone might be able to help. Include the commandline that you typed also.
|
 |
Annie Smith
Ranch Hand
Joined: Mar 05, 2005
Posts: 172
|
|
|
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html
|
Cheers!<br /><b>Annie</b>
|
 |
Ramaswamy Srinivasan
Ranch Hand
Joined: Aug 31, 2004
Posts: 295
|
|
Hi, In the Environment Variables, setting the path variable to the bin of the jdk, should make things work, right? Correct if I am wrong. Cheers, Ram.
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
|
If your program has no package statement, going to the directory where the class file lives should do the trick. See if THIS helps. Let me know if it isn't clear and I'll try to fix it up. Thanks!
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Rick O'Shay
Ranch Hand
Joined: Sep 19, 2004
Posts: 531
|
|
Incorrect: javac -classpath c:\program files\java\jdk\bin MyApp.java You need to put java in your PATH environment variable, preferably near the start. That is the standard place to allow any executable program to be found and not specific to Java of course. The -classpath is strictly for jars and classes. It think you have confused PATH and -classpath. [ September 28, 2005: Message edited by: Rick O'Shay ]
|
 |
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
|
|
See our FAQ: How To Set the Classpath [ September 28, 2005: Message edited by: Joel McNary ]
|
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
|
 |
Rick O'Shay
Ranch Hand
Joined: Sep 19, 2004
Posts: 531
|
|
|
Sadly, the FAQ needs serious rework and simplification including a de-emphasis of the system dependent CLASSPATH variable.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: How to set a class path?
|
|
|