So I have packed my classes and their dependancies (apache commons cli) inside a jar file using one-jar (which was easy enough to do, see section Command-Line Approach). Now I am curious if I can run the java test class inside the jar using a Junit jar outside the class. So the path to the test class inside sw.jar
is :
sw.jar\main\sw.jar\uoa\di\ys11\hw2\TestSmithWaterman.class
(the main\
is a one-jar thing). I have tried variations of :
java -jar -cp lib/junit.jar org.junit.runner.JUnitCore uoa.di.ys11.hw2.TestSmithWaterman
with no luck - so what would the command line be ? Or do I need to modify the one-jar manifest somehow ?
EDIT : the /boot-manifest.mf
:
Manifest-Version: 1.0
Main-Class: com.simontuffs.onejar.Boot
One-Jar-Main-Class: uoa.di.ys11.hw2.Hw2
while the /META-INF/MANIFEST.MF
:
Manifest-Version: 1.0
Created-By: 1.7.0_09 (Oracle Corporation)
Main-Class: com.simontuffs.onejar.Boot
One-Jar-Main-Class: uoa.di.ys11.hw2.Hw2
Use the following command line to test
java -cp lib/junit.jar;sw.jar org.junit.runner.JUnitCore uoa.di.ys11.hw2.TestSmithWaterman
EDIT:
this should be work with normal jars, but the jar is created by the one-jar
One-JAR lets you package a Java application together with its dependency Jars into a single executable Jar file.
After that it's not possible for junit, as I mention junit-4.4 in my case to load such classes for test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With