This content has been marked as final. Show 7 replies
The manifest is irrelevant here. So is the jar, really. It should just be a part of your runtime classpath, like Junit is. That is, don't bother using the -jar bit, that's what's causing your problem. Specifically, the JUnit runner is taking that switch as a commandline arg, and trying to load a class called -jar. Same goes for your jar itself.
jipada wrote:Well they're not arguments that a JUnit runner takes. Doh.
What do you mean the manifest is irrelevent?
I kind of figure out that -jar and jarfile.jar are taken as arguments line (doh)
I was kind of looking for a replacement for the org.junit.runner.JUnitCore that works with jar filesFigure it out for yourself, your sarcasm has bitten you on the @ss. That runner is perfectly adequate for your needs, by the way
jipada wrote:You apparantly do not realize that switches (such as -jar) must be placed before the argument which specifies which class to run.
I'm trying to start a JUnit test from command line.
I've succesfully started it with the java org.junit.runner.JUnitCore MyClass
My problem is that I have my main class in a jar file. The manifest file is pointing to the correct main class but when i use
the java org.junit.runner.JUnitCore -jar myjarfile.jar i get these messages:
Couldn't find class -jar
Couldn;t find class myjarfile.jar
Is there any other way ?
But in this case, a -jar command line option is in direct conflict with a class name to run, because that would mean search the jar file for its manifest to figure out what class to run. You want a -classpath switch, not a -jar switch.
Sarcasm was the last thing on my mind especially at that moment when I was in need of help, but your message just added to my frustration. I've put the jar file in the classpath and add the main class from the manifest file as the argument for junit runner. It works now. You could of said that cause I kind of suspect you knew. Anyway your messages helped. Thanks
jipada wrote:Really? Then I must have misunderstood you. If so, my apologies.
Sarcasm was the last thing on my mind especially at that moment when I was in need of help
but your message just added to my frustration. I've put the jar file in the classpath and add the main class from the manifest file as the argument for junit runner. It works now. You could of said that cause I kind of suspect you knew. Anyway your messages helped. ThanksI did say that. Apart from the "main class from the manifest" bit, which I have no way of knowing, and, in all honesty, is wrong in all but the most simple of cases. Your jar probably consists of more than just the one class, and a fair number of those would be tested, no?
Anyways, you got your solution, which is the main thing