Yahya Cahyadi wrote:
>Hi there.... I'm working on packaging my java program into a neat
>little .app. The app needs to both load other java jars located inside
>my ~/Library/Application Support/MyApp/ and write settings files to
>that folder. I've been tinkering with my Info.plist the whole day
>today, but I still can't figure out how to change the WorkingDirectory
>to some path relative to my home dir, because the Java VM doesn't
>understand "~/" or env variables like "$HOME". Can someone help me out
>here?
If you don't like any of the ideas presented so far, your other choice is
to use a URLClassLoader to refer to the directories you want, and then load
classes from there.
If you don't want to modify your current app to do this, you can wrap your
current app inside another app that sets up the ClassLoaders first, then
invokes your current app's main() method. This would leave your "inner"
app oblivious to how the problem was solved, so it can just do its normal
thing.
If you use the wrapper approach, your Info.plist would have a MainClass of
the wrapper's main(), not your "inner" app's main().
Your wrapper app can also modify system properties before invoking your
inner app. For example, if a property from Info.plist has a ~/ or $HOME/
in it, your wrapper can expand those and change the properties before your
inner app ever sees anything.
Some properties you can change won't have any effect, such as changing the
"java.class.path" or "java.ext.dirs" values. By the time your wrapper's
main() gets invoked, those properties are effectively read-only, because
they've already been used to set up the application and extensions
class-loaders. And ultimately, it's the ClassLoaders that load classes,
not property values. Search the list archives for ListClassLoaders to see
a util for listing the contents of classloaders, i.e. the list of places
from which they load classes.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden