Computer Science, asked by paraspreet3505, 5 months ago

How java runtime(jre) knows where to look for a package that you can create?

Answers

Answered by karthikeyagupta
0

Answer:

The base directory ( $BASE_DIR ) could be located anywhere in the file system. Hence, the Java compiler and runtime must be informed about the location of the $BASE_DIR so as to locate the classes. This is accomplished by an environment variable called CLASSPATH .

Answered by kartavyaguptasl
2

Answer:

Java Runtime Environment (JRE) does not automatically knows the path of the package we have created in Java, but it follows some steps while searching for the path of the created package.

As a default first step, Java run-time environment starts the searching by traversing through the current working directory. Hence, if the package is in any sub-directory of the current directory, JRE will traverse through it and give you the path of the package.

Secondly, we ourselves can specify the path or paths to the directory by setting the environmental variable named CLASSPATH.

Thirdly, We ourselves as user can use the option -classpath with the java and javac in order to specify the path to the required classes or packages.

#SPJ3

Similar questions