What are the values to be entered in PATH environment variable and CLASSPATH environment variable? I have my jdk in the following path k:\program files\java\jdk1.5.0. I already entered CLASSPATH environment variable with "k:\program files\java\jdk1.5.0" and PATH as "k:\program files\java\jdk1.5.0\bin". Still this doesnt work. What should be my PATH and CLASSPATH? Help me.
k:\program files\java\jdk1.5.0 this will allow the imports of all the class files that are there in "k:\program files\java\jdk1.5.0" folder. if u want to include a jar file in ur class path use eg "k:\program files\java\jdk1.5.0\src.jar" -- something like this....
k:\program files\java\jdk1.5.0\bin is fine to run and compile java programs from anywhere on ur computer..
Hope this helps!! Regards Simon [ April 01, 2006: Message edited by: Roy Simon ]
java while installing itself will set the path for its packages. where as the user defined packages has to be informed to the compiler. so make the classpath to say that my class files are at this location.
so right now all the class files available at k:\program files\java\jdk1.5.0 will be made available to the compiler. and i think u would have got the error class not found. if u have encountered this error then probably u would have entered ur import package.*; wrongly.
Regards,
vignesh
Gopi Krrishna
Greenhorn
Joined: Feb 15, 2006
Posts: 12
posted
0
Thanks Simon Roy and Vignesh Hariharan for your valuble suggestions. I've clarified the problem.
Note that everything Roy and Vignesh said about CLASSPATH is wrong. There are no classes in that directory. There are no classes in "src.jar". If you put a directory on the CLASSPATH, jar files in that directory are not searched for classes.
Classes that come in the JDK are not loaded via the CLASSPATH environment variable; therefore, you never need to set CLASSPATH to include the JDK install directory or any component thereof.
I'm sorry if I sound a little peeved, but people have been asking dozens of CLASSPATH questions in the last few days, all of them apparently having been told to set it to the JDK home directory, and all of them have been getting these truly awful answers from people who themselves don't know any better. I'm frustrated with the folks who answer questions when they shouldn't; perhaps more people could read this.
The very best advice about CLASSPATH: go to the control panel and [b]remove any value that you've set.[/i] With no value set, you'll get the default value, which includes the current directory and nothing else. This is perfect.
When you learn more about Java, you'll eventually know enough to decide whether to set it yourself, and what to set it to. Until then, just don't set it at all -- you'll be glad you listened to me.
Originally posted by Ernest Friedman-Hill: Note that everything Roy and Vignesh said about CLASSPATH is wrong. There are no classes in that directory. There are no classes in "src.jar". If you put a directory on the CLASSPATH, jar files in that directory are not searched for classes.
Classes that come in the JDK are not loaded via the CLASSPATH environment variable; therefore, you never need to set CLASSPATH to include the JDK install directory or any component thereof.
I'm sorry if I sound a little peeved, but people have been asking dozens of CLASSPATH questions in the last few days, all of them apparently having been told to set it to the JDK home directory, and all of them have been getting these truly awful answers from people who themselves don't know any better. I'm frustrated with the folks who answer questions when they shouldn't; perhaps more people could read this.
The very best advice about CLASSPATH: go to the control panel and [b]remove any value that you've set.[/i] With no value set, you'll get the default value, which includes the current directory and nothing else. This is perfect.
When you learn more about Java, you'll eventually know enough to decide whether to set it yourself, and what to set it to. Until then, just don't set it at all -- you'll be glad you listened to me.
I didnt say that if u include a folder in the classpath the jar files in that folder will be searched... for jar files, the jar file has to be included in the classpath... only the classfiles which are immediately in that folder will be included....
Regards Simon
Roy Simon
Ranch Hand
Joined: Aug 26, 2005
Posts: 62
posted
0
k:\program files\java\jdk1.5.0 this will allow the imports of all the class files that are there in "k:\program files\java\jdk1.5.0" folder. if u want to include a jar file in ur class path use eg "k:\program files\java\jdk1.5.0\src.jar" -- something like this....
k:\program files\java\jdk1.5.0\bin is fine to run and compile java programs from anywhere on ur computer..
what i meant by import there is that u can just say ClassName obj = new ClassName if the folder location is the classpath and that particular class is not in the classpath.... I think that will work.... (where my test file is in another location..).And abt using jars(with class files in it)... I have bashed their path in the classpath and then imported classes in the jar using the import command.... the Eg of src.jar was only and example.. ok keep it as foo.jar .. I dont see what is wrong with this answer
Correct me if i am wrong, may be there is a misinterpretation here
Regards Simon
vignesh hariharan
Ranch Hand
Joined: Jun 23, 2005
Posts: 77
posted
0
Originally posted by Ernest Friedman-Hill:
Classes that come in the JDK are not loaded via the CLASSPATH environment variable; therefore, you never need to set CLASSPATH to include the JDK install directory or any component thereof.
Originally posted by vignesh hariharan:
java while installing itself will set the path for its packages. where as the user defined packages has to be informed to the compiler. so make the classpath to say that my class files are at this location.
i never said that the classpath is set for the packages that comes from the jdk is done through CLASSPATH environmental variables explicitly by the installer. But one thing.. i think the compiler is informed after the installation of the jdk, that when it encounters java.io.*; (something like this) searches automatically the exact location of those classes(which are not explicitly defined in the CLASSPATH).
that is why i said that "java while installing itself will set the path for its packages"
sorry sir... if i am wrong anyway please help me out rather getting aggravated. anyway i apologise if i am wrong.