Article View: borland.public.jbuilder.java.language
Article #253Re: JAR File Error
From: Paul Furbacher [TeamB]
Date: Wed, 06 Sep 2006 13:55
Date: Wed, 06 Sep 2006 13:55
69 lines
3022 bytes
3022 bytes
vichet wrote:
> [...]
> Yes, it works after i compile it and it returns TRUE. it connects.
> But after i make JAR file. it do not work. i wonder why?
>
> I make like this:
>
> My mainClass file contain: Main-Class: TestConnection
>
> jar cmf mainClass Test.jar *.class
>
> then i run
>
> java -jar Test.jar
>
> it return false
My guess is that you need to include the MySQL JDBC driver
JAR in the classpath. The IDE does this for you when you
add it as a required library. However, when you JAR up
your little application, the required driver classes are
not included. (Note that you are instantiating the driver
class by reflection. This has consequences as to what is
included in the JAR which the Archiver makes.
To do this, change the manifest option of the Archiver node so
that on the "Manifest" page in the Properties dialog.
1. Set it to "Create manifest and save to ...."
2. Rebuild the archive.
3. Open the Application Archive Properties dialog again, and
select option "Override ..." and if necessary use the "..."
browse button to navigate to the src/META-INF folder in your
project and select the manifest file. (This shouldn't be
necessary, but just in case.)
4. Edit the manifest.mf file; insert
Manifest-Version: 1.0
Class-Path: [path-to]/mysql-connector-java-3.1.6-bin.jar
Main-Class: org.pf.teambanswers.DynamicDriverLoader
Here's a reference you should read; it applies to some other
situation but applies to your case (Google +manifest +classpath
for more info):
http://www.iona.com/support/docs/e2a/asp/5.1/j2ee/petstore/tutorial4.html
Read Step 2 thoroughly.
--
Paul Furbacher (TeamB)
Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Technical Details
Message-ID:
<44fed32c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44fe57fa@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,aacdbf63813b8dc0 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 06 Sep 2006 09:55:03 -0400 From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com> Organization: Reverse Alchemy, Inc. User-Agent: Thunderbird 1.5.0.5 (Macintosh/20060719) MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: JAR File Error References: <44fe57fa@newsgroups.borland.com> In-Reply-To: <44fe57fa@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.142.194.228 Message-ID: <44fed32c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1157550892 69.142.194.228 (6 Sep 2006 06:54:52 -0700) Lines: 69 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail