what is the need and use of .; in classpath ?
I kept FirstProgram.java in Test folder of D drive.I set path as C:\Program Files\Java\jdk1.6.0_32\bin in environment variable.
I compiled and got FirstProgram.class in Test folder of D drive.
FirstProgram.java
public class FirstProgram{
public static void main(String args[]){
System.out.println("Welcome");
}
}
I set classpath as D:\Test;.; in environment variable.
When I run the above code by typing java FirstProgram in C drive in DOS prompt,It gave Welcome output.
I modified classpath as D:\Test; in environment variable.
I removed .; from classpath.
When I run the above code by typing java FirstProgram in C drive in DOS prompt,It gave same output.
Then,what is the need and use of adding .; in classpath ?.
Re: what is the need and use of .; in classpath ?
The dot is a way to reference the current folder.
Re: what is the need and use of .; in classpath ?
1. Does Current folder represent the directory of dos prompt from where I run java program ?.
Here I run the above code from C drive in DOS prompt.So here does Current folder (.) represent C directory?.
2. Even after I removed .; from classpath environment variable,code runs perfectly.so what is the need to keep .; in classpath ?.
Re: what is the need and use of .; in classpath ?
The current directory is the default.
java Classname
The above works IF the environment variable is NOT set or if it includes the dot.
The above won't work if Classname is in the current directory and the current directory is not on the classpath.