I'm trying to make a jar file executable, and I've seen numerous questions and answers regarding this particular issue, and none of them helped me with my problem.
I have a batch file that runs the application without any problem, but when I try to create a manifest with the main class attribute copied char by char from my batch file and run it, I get a message "could not find the main class".
I been browsing the web for the past 4 hours* now and the only type of answers I see for that problem is something like this:
This type of solution is worthless to me, since it doesn't tell me why my path is correct when I use the .bat file and incorrect when used in a .jar file.
I read there the related topics.
However, it wasn't even close to being helpful.
I'm using ant and the inner build.xml syntax is probably eluding me somewhere.
In fact, if it was possible to find an example build file that was written for ant 1.6 or later and contains the Main-Class attribute (I've seen some examples that contain an example file, but none of them contained the Main-Class attribute, and I found some Main-Class examples but none of them showed where they should go or how they should appear within the manifest file.
I'm at the point when I'm about to give up the whole idea and provide the unprofessionally looking .bat file.
I thank anyone who has put his mind to this issue, but if there is no build.xml example, I guess you can't help me.
It's frustrating to see how the most flexible language there is to work with when coding, becomes next to impossible to work with when you need to deploy it.
I have managed to figure out that the problem wasn't with the main class, but with the classpath.
I run the program from Intellij, and everything works perfectly. I use a batch file, and perfect. I try to use an Ant generated jar with the classpath attribute set exactly like the batch file's paths, and nothing.
There is no error message either.
The classpath is located under "/lib/*.jar" in the distribution directory, where the "program.jar" is located.
I have come to the point that i would pay to see a proper working build.xml and to see the relative and absolute paths of the classpath.
This is actually harder than developing an extremely rich server application.
Edited by: omerk76 on Apr 30, 2008 11:04 AM
Does your CLASSPATH contain '.' (current directory)? Just a thought, as omitting that absorbed half a day on my previous contract and gave me similar symptoms (OK from a batch file, didn't work as a double-click JAR).
As indicated before, I'm a noob.
My classpath contains many '.'
The problem is that I can't find a simple example for how it should look. I need only a String like: "./name.jar;" or wherever the '.' goes.
I don't have the '.' in my batch that works, I don't have any '.' in the dependencies listing of the application, and if there was a possibility to find a "build.xml"
that has this section in it's manifest file, and produces a working application, probably I would have been able to tell you if I have a '.' in my classpath.
However, since finding the whole String is impossible, I can't tell you if I have it in the correct place.
Anyway it's too late now.
I had 2 days to figure this out, and I failed. I couldn't find the documentation needed, no example file, and in the bottom line, no working application.
We purchased excelsior jet, gave up ant all together, and decided to limit our clients to working under "windows" environments (this is done to allow future .net development , also decided as a consequence of my failure to produce an executable jar, so we won't be dependent again on an api that's documentation is impossible to find).
Sorry for the time consumption, but I guess ant is an api that isn't meant for noobs to work with.
Hope they'll let me have another go in a year or two, and that Ant will ship with a readable documentation and a more significant build file examples, so that inexperienced developers will also be able to know what they should do.