what is the use of PATH & CLASSPATH in java
how to set them for Windows XP?
R6i
That link is out of date. There are instructions in the installation page; if you use Windows try section 4.Rayapudi Murali Krishna wrote: . . . Refer this link
"ye shall know the truth & the truth shall set you free..."
"ye shall know the truth & the truth shall set you free..."
nick kaushik wrote:how to set them for Windows XP?
R6i
Campbell Ritchie wrote:Disagree.
Don't set up a new CLASSPATH variable. You need a PATH, but setting a system CLASSPATH can do more harm than good.
The value suggested is out of date and you should not put that in your CLASSPATH if you are using a version of Java more recent than about 1.2.
R6i
"ye shall know the truth & the truth shall set you free..."
nick kaushik wrote:1 more thing guys--- right now i m saving all my .java files in bin.....would that matter
... & now that i have set Path variable do i need to go any other directory or should i start command prompt & do javac File.java & then java File?
... & also are Path & PATH same?cuz i already have a Path variable in System variables ?
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Agree. I have already suggested how you can do that: mkdir java, as I posted yesterday.Vijitha Kumara wrote:
Is this the bin directory inside JDK then that's a very bad practise. You should have a separate directory for your source files.
I think Windows is case-insensitive, but Unix/Mac/Linux is case-sensitive, so it has to be PATH. Note the use of $PATH rather than %PATH%. Also note there were no error messages for non-existent environment variables..
...
... & also are Path & PATH same?cuz i already have a Path variable in System variables ?
I'm not sure about other OS's but in windows,Yes. You can test this from command prompt (echo %PATH% OR echo %Path% - this is in Vista)
When I changed PATH to path in my .bashrc file, the OS would no longer recognise "java". So it has to be PATH on Linux.campbell@queeg:~$ echo $PATH
/usr/java/jdk1.6.0_16/bin:.:/home/campbell/forth/rvm/rvm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
campbell@queeg:~$ echo $Path
campbell@queeg:~$ echo $CLASSPATH
campbell@queeg:~$ echo $classpath
campbell@queeg:~$
"ye shall know the truth & the truth shall set you free..."
nick kaushik wrote:so Path means directory where javac is located.then how would the system know about where my .java files are located if they are in any other directory?
..& on the same note why doesnt it works from bin?
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
If you put your work into the bin directory, you risk confusion between the installed files and the files you put there. Even worse, if you delete a Java installation directory after upgrading to a new version, all your work will vanish tooVijitha Kumara wrote:
Who said it doesn't work . It works, but a very bad practise.on the same note why doesnt it works from bin?
Regards,
Samaresh Gupte
Samaresh Gupte wrote:My Test.java file on desktop compiles fine.
But java command fails and throws error.
Do I need to set the path of jre's bin in environment variable
C:\Documents and Settings\samareshg\Desktop>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test
Caused by: java.lang.ClassNotFoundException: Test
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Regards,
Samaresh Gupte
SCJP 5,SCWCD 5, RHCT
Campbell Ritchie wrote:What is in your system CLASSPATH? Did you set it up all by yourself?
You might be better deleting the CLASSPATH.
Don't put everything in the desktop; you will have hundreds of things on your desktop and they will vanish when you clear up your desktop. I have told you at least twice in this thread how to create a "java" folder.
Regards,
Samaresh Gupte
Campbell Ritchie wrote:You would probably do better to delete the entire CLASSPATH.
If you need servlets, you are better off adding them to the CLASSPATH with the -cp option when you run the application. If you add them to your CLASSPATH it will become cluttered and you won't know whihc entries are still required.
Regards,
Samaresh Gupte
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |