Javac/Java searching algorithm for other classes


With this post, I would like to explain how exactly the Java/Java will search for its dependencies in the project or application level. Java Applications can be run using the command line or in the Web/Application servers. For both the scenarios will be covered as below:

When you are accessing standalone application using command prompt, below will be the search criteria steps:

Step 1: The first place that look in the directories that contains the classes that come with Java SE.

Step 2: The classpath that declared as command line options for either Java/Javac. Since the classpath declared in command line options override the classpath declared in command line options persists only for the length of the invocation.

Step 3: Looks for the the default classpath that declared as System Environment Variables.

When you are accessing the application from Web or application servers, below will be the search criteria steps:

Step 1: The first place that look in the directories that contains the classes that come with Java SE.

Step 2: If the dependencies not able to identify in the JRE lib folder, then it will be looked into the Application lib folder.

Step 3: If the dependencies not able to fine in above two steps, then it will be looked into Web/App server lib folder.

 

Other Useful Links:

Differences between Object and Instance
Difference between Abstract Class and Interface:
Threads Interview questions in Java
Access Specifiers in Java
Avoid nested loops using Collection Framework in Java

4 thoughts on “Javac/Java searching algorithm for other classes

  1. Divya January 7, 2014 / 10:04 am

    Nice article…. Very helpful….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.