Can I use NetBeans to build an installable package? If so, how? If
not, what should use?
Thanks..
Bruce
|
|
0
|
|
|
|
Reply
|
bruce
|
9/28/2010 11:36:39 PM |
|
On Sep 28, 7:36=A0pm, bruce <bruc...@bellsouth.net> wrote:
> Can I use NetBeans to build an installable package? If so, how? =A0If
> not, what should use?
>
> Thanks..
>
> Bruce
I tried to run the .jar file from the command line and got an error
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
What do I need to do to link the jdbc driver to my code?
Thanks...
Bruce
|
|
0
|
|
|
|
Reply
|
bruce
|
9/29/2010 12:23:49 AM
|
|
In article
<577cd3c9-d2ed-4a86-a311-431e000e0cb5@n3g2000yqb.googlegroups.com>,
bruce <bruceaj@bellsouth.net> wrote:
> On Sep 28, 7:36 pm, bruce <bruc...@bellsouth.net> wrote:
> > Can I use NetBeans to build an installable package? If so, how? If
> > not, what should use?
> >
> > Thanks..
> >
> > Bruce
>
> I tried to run the .jar file from the command line and got an error
>
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>
> What do I need to do to link the jdbc driver to my code?
The driver needs to be on the class path, specified either via the
command line or in the JAR's manifest. When you build the project,
NetBeans puts everything in a folder named "dist" with a README.TXT
that says, in part:
"When you build an Java application project that has a main class, the
IDE automatically copies all of the JAR files on the projects classpath
to your projects dist/lib folder. The IDE also adds each of the JAR
files to the Class-Path element in the application JAR files manifest
file (MANIFEST.MF)."
|
|
0
|
|
|
|
Reply
|
John
|
9/29/2010 12:58:53 AM
|
|
On Sep 28, 8:58=A0pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <577cd3c9-d2ed-4a86-a311-431e000e0...@n3g2000yqb.googlegroups.com>,
>
> =A0bruce <bruc...@bellsouth.net> wrote:
> > On Sep 28, 7:36=A0pm, bruce <bruc...@bellsouth.net> wrote:
> > > Can I use NetBeans to build an installable package? If so, how? =A0If
> > > not, what should use?
>
> > > Thanks..
>
> > > Bruce
>
> > I tried to run the .jar file from the command line and got an error
>
> > =A0 =A0 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>
> > What do I need to do to link the jdbc driver to my code?
>
> The driver needs to be on the class path, specified either via the
> command line or in the JAR's manifest. When you build the project,
> NetBeans puts everything in a folder named "dist" with a README.TXT
> that says, in part:
>
> "When you build an Java application project that has a main class, the
> IDE automatically copies all of the JAR files on the projects classpath
> to your projects dist/lib folder. The IDE also adds each of the JAR
> files to the Class-Path element in the application JAR files manifest
> file (MANIFEST.MF)."
Yah, I read that information. My MANIFEST.MF is:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.6.0_16-b01 (Sun Microsystems Inc.)
Main-Class: CensusRecords.Census1930
Class-Path:
X-COMMENT: Main-Class will be added automatically by build
Do I have to add something to the MANIFEST.MF file? If it's the class
path, how do I find out what it is?
Thanks for the response..
Bruce
|
|
0
|
|
|
|
Reply
|
bruceaj (70)
|
9/29/2010 1:37:50 AM
|
|
In article
<5a2b283e-d278-4484-ae4b-af5dd3175e24@e14g2000yqe.googlegroups.com>,
bruce <bruceaj@bellsouth.net> wrote:
> On Sep 28, 8:58 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > In article
> > <577cd3c9-d2ed-4a86-a311-431e000e0...@n3g2000yqb.googlegroups.com>,
> >
> > bruce <bruc...@bellsouth.net> wrote:
> > > On Sep 28, 7:36 pm, bruce <bruc...@bellsouth.net> wrote:
> > > > Can I use NetBeans to build an installable package? If so, how?
> > > > If not, what should use?
> >
> > > > Thanks..
> >
> > > > Bruce
> >
> > > I tried to run the .jar file from the command line and got an error
> >
> > > java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
> >
> > > What do I need to do to link the jdbc driver to my code?
> >
> > The driver needs to be on the class path, specified either via the
> > command line or in the JAR's manifest. When you build the project,
> > NetBeans puts everything in a folder named "dist" with a README.TXT
> > that says, in part:
> >
> > "When you build an Java application project that has a main class,
> > the IDE automatically copies all of the JAR files on the projects
> > classpath to your projects dist/lib folder. The IDE also adds each
> > of the JAR files to the Class-Path element in the application JAR
> > files manifest file (MANIFEST.MF)."
>
> Yah, I read that information. My MANIFEST.MF is:
>
> Manifest-Version: 1.0
> Ant-Version: Apache Ant 1.8.1
> Created-By: 1.6.0_16-b01 (Sun Microsystems Inc.)
> Main-Class: CensusRecords.Census1930
> Class-Path:
> X-COMMENT: Main-Class will be added automatically by build
>
> Do I have to add something to the MANIFEST.MF file? If it's the class
> path, how do I find out what it is?
It looks like you modified it from the default:
$ cat manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
You can use this utility to see your manifest, as built:
<http://sites.google.com/site/drjohnbmatthews/manifesto>
|
|
0
|
|
|
|
Reply
|
John
|
9/29/2010 2:03:58 AM
|
|
On Sep 28, 10:03=A0pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <5a2b283e-d278-4484-ae4b-af5dd3175...@e14g2000yqe.googlegroups.com>,
>
>
>
> =A0bruce <bruc...@bellsouth.net> wrote:
> > On Sep 28, 8:58=A0pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > > In article
> > > <577cd3c9-d2ed-4a86-a311-431e000e0...@n3g2000yqb.googlegroups.com>,
>
> > > =A0bruce <bruc...@bellsouth.net> wrote:
> > > > On Sep 28, 7:36=A0pm, bruce <bruc...@bellsouth.net> wrote:
> > > > > Can I use NetBeans to build an installable package? If so, how?
> > > > > =A0If not, what should use?
>
> > > > > Thanks..
>
> > > > > Bruce
>
> > > > I tried to run the .jar file from the command line and got an error
>
> > > > =A0 =A0 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>
> > > > What do I need to do to link the jdbc driver to my code?
>
> > > The driver needs to be on the class path, specified either via the
> > > command line or in the JAR's manifest. When you build the project,
> > > NetBeans puts everything in a folder named "dist" with a README.TXT
> > > that says, in part:
>
> > > "When you build an Java application project that has a main class,
> > > the IDE automatically copies all of the JAR files on the projects
> > > classpath to your projects dist/lib folder. The IDE also adds each
> > > of the JAR files to the Class-Path element in the application JAR
> > > files manifest file (MANIFEST.MF)."
>
> > Yah, I read that information. My MANIFEST.MF is:
>
> > Manifest-Version: 1.0
> > Ant-Version: Apache Ant 1.8.1
> > Created-By: 1.6.0_16-b01 (Sun Microsystems Inc.)
> > Main-Class: CensusRecords.Census1930
> > Class-Path:
> > X-COMMENT: Main-Class will be added automatically by build
>
> > Do I have to add something to the MANIFEST.MF file? If it's the class
> > path, how do I find out what it is?
>
> It looks like you modified it from the default:
>
> $ cat manifest.mf
> Manifest-Version: 1.0
> X-COMMENT: Main-Class will be added automatically by build
>
> You can use this utility to see your manifest, as built:
>
> <http://sites.google.com/site/drjohnbmatthews/manifesto>
I "Don't" think I modified my MANIFEST.ME. All I did was load it from
the file list, select All, and copy/paste into my note.
Anyhow, I can now run my application from the command line. I added
mysql-connector-java-5.1.13 to my system CLASSPATH.
Which brings to mind a question! Should I leave mysql-connector-
java-5.1.13 in my system CLASSPATH or move it to my Java CLASSPATH?
Thanks...
Bruce
|
|
0
|
|
|
|
Reply
|
bruceaj (70)
|
9/30/2010 12:23:05 AM
|
|
In article
<81ebded4-f1ed-4353-869d-f67099b5bc18@d25g2000yqc.googlegroups.com>,
bruce <bruceaj@bellsouth.net> wrote:
> > > Yah, I read that information. My MANIFEST.MF is:
> >
> > > Manifest-Version: 1.0
> > > Ant-Version: Apache Ant 1.8.1
> > > Created-By: 1.6.0_16-b01 (Sun Microsystems Inc.)
> > > Main-Class: CensusRecords.Census1930
> > > Class-Path:
> > > X-COMMENT: Main-Class will be added automatically by build
> >
> > > Do I have to add something to the MANIFEST.MF file? If it's the
> > > class path, how do I find out what it is?
> >
> > It looks like you modified it from the default:
> >
> > $ cat manifest.mf
> > Manifest-Version: 1.0
> > X-COMMENT: Main-Class will be added automatically by build
> >
> > You can use this utility to see your manifest, as built:
> >
> > <http://sites.google.com/site/drjohnbmatthews/manifesto>
>
> I "Don't" think I modified my MANIFEST.ME. All I did was load it from
> the file list, select All, and copy/paste into my note.
Try replacing it with the default, and see if NetBeans handles it
correctly.
Turning again to the relevant SSCCE, <http://pastebin.com/nWHciPh0>,
here is the default manifest for a freshly created project:
$ cat manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Build the project:
$ ant jar
....
BUILD SUCCESSFUL
Total time: 0 seconds
As built, the manifest lists the the required JARs:
$ manifest dist/Temp.jar
Manifest: dist/Temp.jar
Ant-Version: Apache Ant 1.7.1
X-COMMENT: Main-Class will be added automatically by build
Class-Path: lib/swing-layout-1.0.4.jar lib/AbsoluteLayout.jar
Manifest-Version: 1.0
Created-By: 1.5.0_24-149 (Apple Inc.)
Main-Class: temp.Main
If your driver JAR is known to NetBeans, it should be among those listed
after Class-Path.
> Anyhow, I can now run my application from the command line. I added
> mysql-connector-java-5.1.13 to my system CLASSPATH.
>
> Which brings to mind a question! Should I leave mysql-connector-
> java-5.1.13 in my system CLASSPATH or move it to my Java CLASSPATH?
I've put JARs in one of the java.ext.dirs in the past, but it inevitably
leads to problems. It's best to specify the class path either via the
command line or in the JAR's manifest.
--
[Can you be trusted to delete signatures, as I asked?]
|
|
0
|
|
|
|
Reply
|
nospam59 (9764)
|
9/30/2010 1:06:39 AM
|
|
bruce wrote:
>> Anyhow, I can now run my application from the command line. I added
>> mysql-connector-java-5.1.13 to my system CLASSPATH.
>>
>> Which brings to mind a question! Should I leave mysql-connector-
>> java-5.1.13 in my system CLASSPATH or move it to my Java CLASSPATH?
John B. Matthews wrote:
> I've put JARs in one of the java.ext.dirs in the past, but it inevitably
> leads to problems. It's best to specify the class path either via the
> command line or in the JAR's manifest.
Classpath management is one of the arcane sciences. It is well worth the time
to read up on it. Links and summary:
<http://download.oracle.com/javase/6/docs/technotes/tools/solaris/java.html#options>
"-jar ... When you use this option, the JAR file is the source of all user
classes, and other user class path settings are ignored."
<http://download.oracle.com/javase/tutorial/deployment/jar/downman.html>
<http://download.oracle.com/javase/tutorial/deployment/jar/manifestindex.html>
<http://download.oracle.com/javase/6/docs/technotes/tools/solaris/jar.html>
<http://download.oracle.com/javase/tutorial/essential/environment/paths.html>
java.ext.dirs serve a special, special purpose. An extension is not a simple
classpath element. It transforms the Java platform itself into a
special-purpose environment. It applies to every regular application. (I'm
pretty sure the "-jar" classpath blockage applies to extension directories,
however.) In effect, extensions become part of Java itself for that platform.
Regular classpath elements are nodes for conventional libraries. Regular
classpaths are those specified in the CLASSPATH envar, tools' "-classpath" and
"-cp" options, and JAR manifests when run under "-jar".
CLASSPATH, like extensions, applies to all non-"-jar" executions, regardless.
It's convenient when you really do want to specify common library search
paths for all Java things at a level less than extending the platform. I
consider this need rare.
Classpath tool options are best for running Java things under the control of
your local preferences. A command "java -cp <whatever> ..." gives the
invoking Java control of the classpath. It's far more flexible than the
CLASSPATH envar.
JAR manifest "Class-Path:" serves the primary purpose of a JAR - to provide a
self-contained delivery mechanism for a library or application. It overrides
the invoking "java" classpath to give the JAR itself command of the classpath.
The catch to JAR manifest "Class-Path:" is that the referenced library JARs
have to live outside the commanding JAR in the host filesystem, not within the
JAR itself. A full JAR-based deployment would be something like a ZIP holding
the application JAR and its helper JARs in relative paths to the main one.
The user unpacks the ZIP into a target directory on their system and voilà.
That's downward-relative. Use of "../" in JAR paths is ill-advised. Same
directory or relative "lib/" are two suggestions.
--
Lew
|
|
0
|
|
|
|
Reply
|
noone7 (3512)
|
9/30/2010 2:20:33 AM
|
|
|
7 Replies
225 Views
(page loaded in 0.126 seconds)
|