By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

How do I tell "jar" to include within a jar everything that a given applet or application requires?

P: n/a
I have gotten to the point where attempting to run my application using
"java -jar HotSpotImageTest.jar" no longer generates a complaint about not
finding function main. It turned out that the problem was that there was a
package statement as the first line of the code generated by Borland's
JBuilder IDE. Yes, I used JBuidler's form designer to create it. I don't
normally worry about adding "package" to code I write, and didn't much care
as long as it worked. But as it turns out, it meant that I had to run "jar"
in the parent directory of the directory having the same name as the package
and the latter directory had to be the root directory to which all paths in
the project are relative.

The project now runs up to the point where the one object instantiating a
class in Borland's library that I used is used. At this point, it complains
about not finding the class. I know the proximate cause of this is related
to the classpath, and the short term fix is to specify one, but this is not
an adequate solution as I can't expect all users, or in fact any of them, to
install JBuilder, let alone install it to the same place I did.

The only option I see, to support deployment, is to package the bytecode for
everything my application uses (including swing, in case any user might have
a machine with an older version of Java that doesn't support swing. But,
HOW DO I DO THIS? And, assuming I CAN do this, how do I tell if it is using
the copy of swing embedded in the jar rather than that in the SDK directory
tree?

Thanks,

Ted
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ted Byers wrote:

The project now runs up to the point where the one object instantiating a
class in Borland's library that I used is used. At this point, it complains
about not finding the class. I know the proximate cause of this is related
to the classpath, and the short term fix is to specify one, but this is not
an adequate solution as I can't expect all users, or in fact any of them, to
install JBuilder, let alone install it to the same place I did.

The only option I see, to support deployment, is to package the bytecode for
everything my application uses (including swing, in case any user might have
a machine with an older version of Java that doesn't support swing. But,
HOW DO I DO THIS? And, assuming I CAN do this, how do I tell if it is using
the copy of swing embedded in the jar rather than that in the SDK directory
tree?


Ted,

You have a couple of options. First, you should verify that the Borland
libraries are redistributable without cost.

You could package everything together in one jar file, but another
technique is preferred. In the MANIFEST.MF file, you can add a
Class-Path entry. The Class-Path entry contains the CLASSPATH of your
application. Each piece of the CLASSPATH should be separated by a
space. The pieces are interpreted as relative to the directory
containing the jar file. So if Borland gives you borland.jar you can
put the jars in the same directory and have:

Class-Path: borland.jar

in your MANIFEST.MF.
Now, you also mentioned packaging swing. I wouldn't recommend it.
First, it is very large. Second, if the JVM you are running on does not
already have swing it probably doesn't have a lot of new stuff from
later versions of Java. Stuff that you might also be using.... The
best bet is to determine the lowest version of Java your stuff compiles
and runs on and force your users to have at least that version. You can
check the version with System.getProperties() (see the javadoc).

Ray


Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.