Java is an OOP language. In java programming language for compiling the program we use the compiler that converts the source code into the byte code after that, that byte code is interpreted by JVM that converts the bytecode into the machine independent code. In java how the Java compiler and the JVM use the class search path to locate classes when they are referenced by other Java code. Searching class path is important for all Java developers.Many development tools have their own ways of manipulating the class path, which vary from product to product.For doing this we will use only simple command-line tools to carry out the compile operations. No difference, between the way that the Java compiler searches for classes, and the way that the JVM does it at run time. The compiler has the ability to compile classes from source code, where the JVM does not. We will use the compiler, but similar issues apply at run time.
Searching of multiple class directories
For Unix like this :
For Windows like this:
The difference is that Windows uses the colon (:) character as part of a filename, so it can't be used as a filename separator. Naturally the directory separator character is different as well: forward slash (/) for Unix and backslash (\) for Windows.
Searching of multiple class directories
- javac (compiler) search the files in only one directory at a time.
- But, class search path will contain numerous directories and JAR archives. The -classpath option to javac and java allows multiple entries to be specified, but the syntax is different for Unix and Windows systems.
For Unix like this :
javac -classpath dir1:dir2:dir3 ...
For Windows like this:
javac -classpath dir1;dir2;dir3 ...
The difference is that Windows uses the colon (:) character as part of a filename, so it can't be used as a filename separator. Naturally the directory separator character is different as well: forward slash (/) for Unix and backslash (\) for Windows.
No comments:
Post a Comment