Reputation: 1
is there any diff between run a java program with jar or with a package unpacked? now i meet a Weird probem. i have a search program.when i run it with a jar,it's ok. when i run it just with package unpacked to jar ,then the gc log is a
Upvotes: 0
Views: 415
Reputation: 29179
To expand slightly on the answer from AlexR; There is no difference from the JVM point of view, however there can be difference from a resource point of view.
That is:
java -cp test.jar com.company.test
and
unzip -d test test.jar
java -cp test com.company.test
Can produce different results in certain very specific circumstances. The only one that I can think of off the top of my head is to when reading a ZIP file resource. The standard resource reader that retrieves a resource from a JAR file, cannot be then passed to ZipFileReader, whereas a resource passed in from a file on disk can be.
That said, given the differences that you are seeing, this is unlikely to be your problem, and the course is almost certainly one of:
java -jar test.jar
and java -cp test.jar com.company.test
are not the same thing, and could have different classpaths.Look at AlexR's answer for other suggestions.
Upvotes: 1
Reputation: 115388
There is no difference from JVM perspective. JVM knows to load classes from file system or from zip file transparently.
I do not exactly understand which GC log is this but I strongly believe that if you have any difference in running your java program from jar or from unpacked classpath it may be caused by
And another option is if the program you are trying to run deals programmatically (on application layer) with its own classpath. I saw program that assumes that it must be executed from jar named like mycompany.jar
. Otherwise it did not work.
Upvotes: 1