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: LSEnvironment works for Java apps?



Eric Wasserman <email@hidden> wrote:

>How do I know it's not working? When I
>Runtime.getRuntime().exec("/usr/bin/env") I
>don't find the added variables. Is this supposed to work for bundled Java
>apps?

That may depend on the app (i.e. your Java IDE's launcher).


Have you tried the exec() variant that takes a String[] of environment
variables?

I have not tried it, but it would seem to solve your problem if you can
first get the current value of the PATH variable. It (or indeed any
env-var) can be obtained in a couple of ways.

One way is to exec() /usr/bin/env and parse the resulting output. A
BufferedReader and a scan for a lineWhich.startsWith( "PATH=" ) should
suffice to identify the line of interest.

Or you could use my open source Suite/P Toolkit:
<http://www.amug.org/~glguerin/sw/#suitep>

With system properties defined properly, all it takes is:
String envPATH = Suite.getSuite().getString( "env.PATH" );


>What I'm really trying to do is put the commandline utility "p4" on a Java
>IDE's path [so] one of its plugins that does perforce commands by exec'ing
>will work.

Which Java IDE?

In any case, I don't recommend messing with the IDE's own environment. It
will be much safer if the plugin sets the PATH variable only for the
commands it exec()'s. Refer to the API docs for the Runtime.exec()
methods, and only use the ones that take String[] args, to avoid any
quoting issues.

If the plugin blindly assumes the perforce commands are already in PATH,
then that seems like a shortcoming of the plugin.


>2) launching the IDE from the command line using "open" where I've added
>the "p4" commands path in the usual bash way. This is just a pain.

>Next step, I suppose will be to replace the IDE's launcher by a shell
>script that sets up the environment then calls ...ugh.

It's not so bad. On 10.2+, you can put a prelude shell-script in the IDE's
app-bundle. In the prelude, you can do anything available to the shell,
including:
PATH="${PATH}:/usr/local/bin/"

For a discussion and examples, see:
<http://www.amug.org/~glguerin/howto/More-open-files.html>


I'll also mention that this:
$PATH:/usr/local/bin/p4

will fail unless "p4" is a directory. As given, it will also fail in tcsh,
but for a different reason: in tcsh, :'s are significant in shell-var
expansions.

It's not clear to me from what you wrote whether "p4" is a command or a
directory, so I can't say whether the example you gave is correct or not,
but it seems like it might be problematic.

In any case, patterns will not be expanded in ~/.MacOSX/environment.plist,
or any other plist, as far as I know. As a result, the LSEnvironment
dictionary in Info.plist suffers the same plight as the
~/.MacOSX/environment.plist file. That is, you can't expand the $PATH
pattern. So even if LSEnvironment works, you still can't append to the
PATH env-var. The best you could do would be to set a specific PATH, and
I'm not sure how well that would work here.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
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.