Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to handle .command launch directory?



Scott Ellsworth <email@hidden> wrote:

>I have a .sh file that launches one of my programs. I do not know what
>directory the jar will be in, save that the .sh file will be in the
>same place. The current .sh file reads:
>
>java -Xms128MB -Xmx512MB -jar test.jar -propfile=test.properties
>
>and works just fine when launched from the directory it, test.jar, and
>test.properties are in.
>
>I just turned it into a .command file, and while it still works from
>the working directory, double clicking it launches it from somewhere
>else, causing it to fail.
>
>Any suggestions on how I can find the directory of the .command file
>launched, so I can find my jar?

You could put the .command file in a specific known location, such as ~/bin
or /usr/local/bin, and put the jar in the same place. Then make an alias
to the .command file and move or copy that anywhere.

You could put the .command file anywhere, and put the jar in a known
always-searched place, such as ~/Library/Java/Extensions. You might have
to make that directory if it doesn't already exist. Also, you would have
to use the command:
java -jar ~/Library/Java/Extensions/test.jar -propfile=~/test.properties

which then makes it moot exactly where the jar itself is placed. However,
for jars that are in any of the Java extensions locations, you can run any
main() in any extension jar as:
java -options -here fully.qualified.name.of.Main args

without a -jar or -cp option, and it will work. If the jar is located in a
shared extension location, then all users can run any commands or utilities
it contains. However, writing to a shared extension location requires root
privileges, which may not be appropriate to a nightly build procedure.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.