The Wayback Machine - https://web.archive.org/web/20240802143601/https://www.geeksforgeeks.org/difference-between-url-uri-and-urn-in-java/
Open In App

Difference Between URL, URI and URN in Java

Last Updated : 15 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report

URI stands for Uniform Resource Identifier. URI is a sequence of characters used to identify a resource location or a name or both over the World Wide Web. A URI can be further classified as a locator, a name, or both.

Syntax of URI: Starts with a scheme followed by a colon character, and then by a scheme-specific part. 

The most popular URI schemes, are HTTP, HTTPS, and FTP.

URL stands for Uniform Resource Location. URL is a subset of URI 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 a 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.

URN stands for Uniform Resource Name. It is a URI that uses a URN scheme. 

“urn” scheme: It is followed by a namespace identifier, followed by a colon, followed by namespace specific string

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.

URI  URL URN
URI stands for Uniform Resource Identifier. URL stands for Uniform Resource Location. URN stands for Uniform Resource Name.
URI is a superset of URL & URN URL is a subset of URI. URN  is a subset of URI.
It is used to identify a resource on the internet either by location or name or both. It is used to identify a resource on the internet either by location. It uniquely identifies the resource by name.
URI is not always a URL All URLs are URIs All URNs are URIs
URI includes components like scheme, authority, path, query, etc. URL includes protocol, domain, path, hash, query, string etc. URN does not include any component.

Examples:

  • https://www.example.com/page.html
  • urn:isbn:0451450523

Examples:

  • https://www.geeksforgeeks.org/
  • https://www.example.com/page.html

Examples:

  • urn:isbn:0451450523
  • urn:ietf:rfc:3986

Here is a diagram that shows the relationship between URL, URI, URN:

URL, URI, URN in Java



Similar Reads

Difference Between URI and URN in Java
URI stands for Uniform Resource Identifier. It identifies the resource either by name, or by location, or by both. It allows uniform identification of the resources. Here the resource can be anything like documents, images, files, web pages, etc. that can be part of the web architecture. The identifier in the name URI refers to the prominence of th
2 min read
Difference Between URL and URN in Java
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 r
3 min read
Difference Between URL and URI
In Web browsers and Internet connections, it is important to understand the difference between a Uniform Resource Identifier (URI) and a Uniform Resource Location (URL). Both URIs and URLs are pointers to things like web pages, images, documents, or other online content. However, they have distinctive characteristics and functions that set them apa
7 min read
URI getRawAuthority() method in Java with Examples
The getRawAuthority() function is a part of URI class. The function getRawAuthority() returns the raw authority of a specified URI. This function returns the exact value of host name and post without decoding the sequence of escaped octets if any. Function Signature: public String getRawAuthority() Syntax: url.getRawAuthority() Parameter This funct
3 min read
URI getAuthority() method in Java with Examples
The getAuthority() function is a part of URI class. The function getAuthority() returns the authority of a specified URI. The Authority part of the URL is the host name and the port of the URI. Function Signature public String getAuthority() Syntax: url.getAuthority() Parameter This function does not require any parameter Return Type The function r
3 min read
Spring MVC Optional @PathVariable in Request URI
Spring MVC becomes even more easy with the use of the @PathVariable annotation and by the use of Optional classes within the Request URI to make robust Spring Applications. In this article, we will look into the necessity of the two components, delving into their prerequisites and understanding why Optionals are essential in handling scenarios wher
3 min read
Difference between URL and Link
1. Uniform Resource Locator (URL) : A URL stands for Uniform Resource Locator which specifies the distinct address for each resource on the internet. So, simply they are the means on which the network or internet are located. 2. LINK : It is an element that is in the form of an electronic document that links to some other place in the same or diffe
2 min read
Difference Between Domain Name and URL
In the world of the internet and websites, Domain Name and URL are very common terms and are used interchangeably, but there is a lot of difference between these two terms. In this article, we will learn what the difference is between a domain name and a URL. Domain NameIt is very hard to remember the IP address of the server. Hence, the domain nam
3 min read
java.net.URL Class in Java
URL is an acronym of Uniform resource locator. It is a pointer to locate resource in www (World Wide Web). A resource can be anything from a simple text file to any other like images, file directory etc. The typical URL may look like http://www.example.com:80/index.htmlThe URL has the following parts: Protocol: In this case the protocol is HTTP, It
4 min read
Difference Between java.sql.Time, java.sql.Timestamp and java.sql.Date in Java
Across the software projects, we are using java.sql.Time, java.sql.Timestamp and java.sql.Date in many instances. Whenever the java application interacts with the database, we should use these instead of java.util.Date. The reason is JDBC i.e. java database connectivity uses these to identify SQL Date and Timestamp. Here let us see the differences
7 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg