Skip to content
Related Articles

Related Articles

Improve Article

Difference Between URL and URN in Java

  • Last Updated : 06 Jun, 2021

URL stands for Uniform Resource Location. A URL contains a protocol, server name or IP Address, Port Number, filename, or directory name. URL is a subset of URI as perceived from the image shown below that describes the network address or location where the source is available.  URL begins with the name of the protocol to be used for accessing the resource and then specific resource location. URLs build on the Domain Name Service (DNS) to address hosts symbolically and use a file-path-like syntax to identify specific resources at a given host. For this reason, mapping URLs to physical resources is straightforward and is implemented by various Web browsers.

Here, the uniform is related to the uniform identification of the web resources/network-resource i.e. any static or dynamic files hosted on a particular network. And we need a standard way to identifies the particular file or resource by their location means it basically contains information about how we can fetch the resource by using location. Generally, we named a URL as a web address.


An XML file does not appear to have any style information associated with ii for which the document tree is as follows:

<Message>The specified key does not exist.</Message>

From the above XML file we can get a fair understanding as follows:

  1. HTTPS is a protocol that we are using.
  2. media.geeksforgeeks.orgis the server name for which access is denied because of security and maintaining privacy of the organization.
  3. /wp-content/uploads/2021030515058/ is the directory name and g.png is the file name.

Now dwelling on the second concept which is closely related.

URN stands for Uniform Resource Name. It is a URI that uses a URN scheme. URL identifies the web resources/network resource by name in a given namespace followed by colons, followed by namespace specific strings. URN does not imply the availability of the identified resource.URNs are location-independent resource identifiers and are designed to make it easy to map other namespaces into URN space.


<URN> ::= "urn:" [NID] ":" [NSS]

Note: NID is a namespace identifier and NSS is a namespace specific string.


If it is customary to search on Google the image depicts out that 

  1. urn is a Uniform Resource Name.
  2. isbn is a namespace identifier. ISBN is used to identify books by book number, it is International Standard Book Number.
  3. 0451450523 is namespace specific string which is the book number.

Now after having adequate knowledge of both URL and URN, let do conclude out major differences between them which are listed in the tabular format below as follows:

URL is also called Uniform Resource LocatorURN is also called Uniform Resource Name
It uses location to fetch the resource from the network.It is used to fetch the resource by name.
A URL contains a protocol, IP address, port number, directory name, host, etc.It starts with the prefix urn followed by a namespace identifier, followed by a namespace specific string.

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :