• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Java application packaging questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java application packaging questions


  • Subject: Re: Java application packaging questions
  • From: Joseph Jones <email@hidden>
  • Date: Sat, 9 Aug 2003 12:55:58 -0700

Got it! The new jar file is all I need it appears. Thank you all for your help in this matter!

Thanx,
joe

On Saturday, August 9, 2003, at 12:03 PM, Erik Price wrote:


On Saturday, August 9, 2003, at 12:19 PM, Joseph Jones wrote:

I DO want the jar files in the same path as my class file. I have tried both setting the classpath cl arg and the CLASSPATH env var to the current directory (.) to force the lookup, but to no avail.

When I created the double clickable JAR file using JAR Builder, I explicitly added those two file to the class path. However, the ceated JAR file didn't work for beans.

Hm. I don't have any experience w/JAR Builder per se, rather I build jars manually with the jar command.

Create a temporary directory, say ~/tmp. In ~/tmp, create a folder called "lib" (~/tmp/lib). Put the two external JAR files in ~/tmp/lib. Now put all of your project's class files (however few they may actually be, since you mentioned it's really just a wrapper interface) in the main ~/tmp directory. Make sure that you have the proper package hierarchy per the Java language spec (such as class com.jones.Foo in ~/tmp/com/jones/). So now you have this hierarchy:

~/
tmp/
lib/
1st_external.jar
2nd_external.jar
com/
jones/
Foo.class

Now create a MANIFEST.MF file in ~/tmp which contains the Main-Class directive pointing to your "driver" class (which is the class with a public static void main), and a Class-Path directive pointing to the external jars in ~/tmp/lib:

#contents of MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.4.1_01 (Sun Microsystems Inc.)
Main-Class: NameOfYourDriverClassHere
Class-Path: lib/1st_external.jar lib/2nd_external.jar
#end contents of MANIFEST.MF

Now, in Terminal, you need to create a JAR file of your project's files, including the MANIFEST.MF, but not including the files in ~/tmp/lib:

jar -cf MyProject.jar -m ./MANIFEST.MF com/jones/Foo.class com/jones/Driver.class ...etc...

This will create a third JAR file, ~/tmp/MyProject.jar. Note that it is separate from the JARs that you put into 'lib', but its manifest file will "know" the path to those JARs so that when you execute this JAR file, the JVM will be able to find the classes it needs from inside of those jars. The Main-Class directive indicates to the JVM which class in your MyProject.jar contains the public static void main method which should be executed to run the program.


I could create an appleiscript (or shell script) to do the copy, but that would still require sudo access unless there is a way to put them into the users ~/Library somewhere.

I must confess that I don't know much about AS, but surely there must be a way to prompt the user for a root password in a secure manner (such as using Keychain, etc).



I'm going away for the night so hopefully this made enough sense, but if it doesn't work then post again to cocoa-dev@omni and I'll be back tomorrow night. Good luck,


Erik


Joseph Jones
JTech Softworks, Inc. - http://www.jtechsoftworks.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Custom layout
  • Next by Date: Scrolling Thumbnails (Like Preview)
  • Previous by thread: Re: Java application packaging questions
  • Next by thread: obj-c/java, which is better and why?
  • Index(es):
    • Date
    • Thread