URL for jar file
In this chapter you will learn:
URL to referencing jar file in the file system
The following code creates a URL that refers to a jar file in the file system.
import java.net.URL;
/*from jav a2s . co m*/
public class Main {
public static void main(String[] argv) throws Exception {
URL url = new URL("jar:file:/c://my.jar!/");
System.out.println(url);
}
}
The code above generates the following result.
URL for single file in a jar file
The following code creates a URL that refers to an entry in the jar file
import java.net.URL;
/* jav a2 s . c o m*/
public class Main {
public static void main(String[] argv) throws Exception {
URL url = new URL("jar:file:/c://my.jar!/com/mycompany/MyClass.class");
System.out.println(url);
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » URL URI