File tree Expand file tree Collapse file tree
core-java-modules/core-java-jar
main/java/com/baeldung/jar
test/java/com/baeldung/jar Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ This module contains articles about JAR files
88- [ Importance of Main Manifest Attribute in a Self-Executing JAR] ( http://www.baeldung.com/java-jar-executable-manifest-main-class )
99- [ Guide to Creating and Running a Jar File in Java] ( https://www.baeldung.com/java-create-jar )
1010- [ Get Names of Classes Inside a JAR File] ( https://www.baeldung.com/jar-file-get-class-names )
11+ [ Find All Jars Containing Given Class] ( https://baeldung.com/find-all-jars-containing-given-class/ )
Original file line number Diff line number Diff line change 1+ package com .baeldung .jar ;
2+
3+ import com .fasterxml .jackson .databind .ObjectMapper ;
4+
5+ import java .net .URL ;
6+
7+ public class JarApp {
8+
9+ public static String findObjectMapperClass () {
10+ Class <ObjectMapper > klass = ObjectMapper .class ;
11+ URL path = klass .getProtectionDomain ().getCodeSource ().getLocation ();
12+ return path .toString ();
13+ }
14+
15+ public static void main (String [] args ) {
16+ System .out .println (findObjectMapperClass ());
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .jar ;
2+
3+ import org .junit .Assert ;
4+ import org .junit .jupiter .api .Test ;
5+
6+ public class JarAppUnitTest {
7+
8+ @ Test
9+ public void findClassTest (){
10+ Assert .assertTrue (JarApp .findObjectMapperClass ().endsWith ("jackson-databind-2.13.0.jar" ));
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments