Quote:
quote:Originally posted by ekta
kindly tell everything related to classpath n other
environment variables available for Java2 in windows 98.
|
Sorry, I can't answer that, although I too use win98, so I might be able to answer more specific questions. I suggest you read the book.
Quote:
|
quote:wats the role of classpath while using packages.
|
I don't know if you've ever tried to compile and execute a file that is part of a package, but Java doesn't make it very easy. Given this directory structure:
C:
--javaPrograms folder
------Pack1 folder
------------DemoA.java
The only way I have figured out to compile(javac) a source file(.java) is to change the DOS prompt to the folder containing the source file:
C:\javaPrograms\Pack1>
and then compiling:
C:\javaPrograms\Pack1> javac DemoA.java
When you are executing(java) your program, the classpath tells java where to look for the package folder. One way you can tell java where to look for the package folder is with the classpath flag. In the classpath flag, you specify the folder that contains the package folder:
C:\javaPrograms\Pack1> java -classpath C:\javaPrograms Pack1.DemoA
Or, you can permanently set the CLASSPATH environment variable, which does the same thing as the classpath flag, but it is a permanent setting. That means java will search all the directories listed under CLASSPATH for the package, and you don't need to include the classpath flag in the java command to execute your program.
You should note that if you switch the DOS prompt to the directory/folder that contains the package folder, you can execute your program without specifying a classpath flag or setting the CLASSPATH environment variable. For instance, in the above example, if you change the DOS prompt:
C:\javaPrograms\Pack1> cd ..
to get the prompt:
C:\javaPrograms>
You can execute the program from there like this:
C:\javaPrograms> java Pack1.DemoA