I´m running some test and I need to get the path of a file that it´s in a jar lib that I have in my project as dependency.
This jar is not part of the classpath that I run.
If I try something like
val path = getClass.getResource("h2-1.3.161.jar").getPath
java -cp //file:/D:/Users/nb38tv/workspace/f2e-core/f2e-mock/f2e-test-framework/target/f2e-test-framework-1.8.3-SNAPSHOT.jar!/h2/sakila-h2-master/h2-1.3.161.jar -ifExists -tcp -web -tcpAllowOthers
Unrecognized option: -ifExists
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Is the file a .class file? Can you open the file in your test? Can you instantiate a class from that jar file?
To get to the location of a class you can use the following method: System.out.println(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath());