It is possible run a jar that I have inside another jar from my class?
I´m trying to run this command from my class
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
But java complain since cannot find the jar.
If I remove the !
from the path I receive this error
Unrecognized option: -ifExists
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
It is not possible to execute a jar embedded in a jar like that, but even if it were possible, your Java command line is simply incorrect. That is because the -ifExists
(and the other options) are interpreted as commandline options of the java
executable.
You will get the same error message if you extract that h2-1.3.161.jar
from the f2e-test-framework-1.8.3-SNAPSHOT.jar
and tried to execute it with the same command line.
It would either need to use -jar
instead of -cp
, or you would need to specify the class to run before -ifExists
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.