Java files work but jar files do not
Hello everyone!
My java files run normally and I get a response that I expect (which is successful). Imagine my surprise when I collected them in a Jar and the very same files inside the jar no longer work! I get a response (still generated by my java program) from successful, it turns to Query Expire.
My problem is, when executed as normal java programs, the expected result is produced. However, when the jars are executed, the result is expired. What is wrong? The classes and the ones in the jar are the same. Is there something different with the mechanism of Jars that make it erroneous?
Many thanks in advance. I have been working with this for a week with no progress! =(
[706 byte] By [
ajuaa] at [2007-10-2 20:25:17]

I don't know what this "Query Expire" output means, but I think you should post exactly:- how you run your main class and what output you expect (and actually get)- how you run your jar exactly, and what error or output you get
Lokoa at 2007-7-13 23:08:12 >

Hi!
Thanks for your reply. Here's what's happening so far:
I created my java files using Eclipse and using the Export option, I exported them as a JAR.
When I run my application on Eclipse with the Java files in tow, the output I expect is Done sending: wait for responses now
Received response from billing api- A: null(0), C: 13, E: Account already registered
Register: Failed: 1 Failure(s)
Now, on to the JAR file.
I executed the JAR file using the command java -jar <jar name.jar>
Here's the response:
Done sending: wait for responses now
Received response from billing api- A: null(0), C: -1, E: Query expire w/o response
Register: Failed: 1 Failure(s)
My program communicates with a database and this generates the reply that should be received by my program. My ordinary Java file gets the expected output, but the JAR does not.
Is it possible that the JAR file somehow slows down the transaction? The reply sent by the database isn't received by the JAR -- somehow, the message gets lost.
ajuaa at 2007-7-13 23:08:12 >

> Is it possible that the JAR file somehow slows down the transaction?
This is very very doubtful.
Are you certain that in the jar case, there aren't any other errors being shown on the console? The thing is, you start your .class files from Eclipse, but your jar from outside. There must be a difference. I suspect you need some classes on the classpath but Eclipse is doing this for you. Which would mean in the jar case you'd see some NoClassDefFoundErrors.
What I'd do is try to run the .class file outside Eclipse as well, and see what happens. I would expect this to yield the exact same result as running the jar.
Lokoa at 2007-7-13 23:08:12 >

> What I'd do is try to run the .class file outside
> Eclipse as well, and see what happens. I would expect
> this to yield the exact same result as running the
> jar.
I'd do the same thing. For 2 reasons:
1) When running prgram in Eclipse, it usually does not have to access resources and other things in jar file (which is zipped)
2) Eclipse (at least version 3.1) creates jar files whose manifest file does not contain the classpath line. U have to add it there manually.
For instructions how to write manifest file, see: http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html