I should mention, if the code above is run from inside Eclipse (or some
other IDE _not_ launched from the Terminal), the system path will not
include any of the paths that may of been added in .profile or
.bash_profile. On Mac OS X at least, if you want to add a new path to the
global system PATH environment variable, you edit the /etc/paths file.

-- jim

On Fri, Aug 28, 2009 at 9:32 AM, James Cook <[email protected]> wrote:

> Hi Logan,
>
> My understanding was when launching Java from the terminal, Runtime.exec()
> will have full access to the system path of the current process (unless you
> override them). That is what the second parameter to Runtime.exec() is for.
> Is this not the case?
>
> Since JDK 5, I've preferred to use ProcessBuilder.
>
> import java.io.*;
>
> public class Paths {
>
>         public static void main(String[] args) {
>                 System.out.printf("PATH environment variable is: %s\n\n",
> System.getenv("PATH"));
>
>                 try {
>                         String[] cmd = {"/bin/bash", "-c", "echo $PATH"};
>                         Process process = new ProcessBuilder(cmd).start();
>
>                         InputStream is = process.getInputStream();
>                         InputStreamReader isr = new InputStreamReader(is);
>                         BufferedReader br = new BufferedReader(isr);
>
>                         String line;
>                         while ((line = br.readLine()) != null) {
>                                 System.out.println(line);
>                         }
>
>                 } catch (Throwable t) {
>                         t.printStackTrace();
>                 }
>         }
> }
>
> They two paths output are the same on my Mac when I run the class from
> Terminal.
>
> -- jim
>
> On Thu, Aug 27, 2009 at 5:30 PM, Logan Allred <[email protected]> wrote:
>
>>
>> Runtime.exec() in java doesn't honor your .profile or other settings
>> that alter the default path and other environment variables. So just
>> because it runs from the shell, doesn't mean it will run in java.
>>
>> Logan
>>
>> On Thu, Aug 27, 2009 at 1:08 PM, wlepinski<[email protected]> wrote:
>> >
>> > is exactly what happens. When I run the flashplayer from the command
>> > line it opens normally. But when I run mvn clean install that does not
>> > happen and I get an error saying that flash player can not be
>> > executed.
>> >
>> > =/
>> >
>> > On Aug 27, 3:16 pm, Marvin Froeder <[email protected]> wrote:
>> >> Ow man....
>> >> Something is very wrong there...
>> >>
>> >> You are saying that if you run FlashPlayer.exe on command line it
>> launches
>> >> FP and when you run mvn clean install flexmojos can't launch FP?
>> >>
>> >> Makes no sense to me =/
>> >>
>> >> VELO
>> >>
>> >>
>> >>
>> >> On Thu, Aug 27, 2009 at 1:13 PM, wlepinski <[email protected]> wrote:
>> >>
>> >> > works....
>> >>
>> >> > On Aug 27, 12:21 pm, Marvin Froeder <[email protected]> wrote:
>> >> > > Not sure what you mean, but on command line, if you run$
>> flashplayer
>> >>
>> >> > > Does it work?
>> >>
>> >> > > VELO
>> >>
>> >> > > On Thu, Aug 27, 2009 at 11:38 AM, wlepinski <[email protected]>
>> wrote:
>> >>
>> >> > > > because don't affect the plugin.
>> >>
>> >> > > > On Aug 27, 11:19 am, Marvin Froeder <[email protected]> wrote:
>> >> > > > > I wounder why you can put it on OS path?!
>> >> > > > > VELO
>> >>
>> >> > > > > On Thu, Aug 27, 2009 at 11:00 AM, wlepinski <[email protected]>
>> >> > wrote:
>> >>
>> >> > > > > > this not work for me.
>> >>
>> >> > > > > > <build>
>> >> > > > > >               <plugins>
>> >> > > > > >                       <plugin>
>> >> > > > > >
>> <groupId>org.sonatype.flexmojos</
>> >> > > > > > groupId>
>> >> > > > > >                               <version>3.3.0</version>
>> >> > > > > >  <artifactId>flexmojos-maven-plugin</artifactId>
>> >> > > > > >                               <extensions>true</extensions>
>> >> > > > > >                               <configuration>
>> >> > > > > >                                       <testRunner>
>> >> > > > > >                                               <launcher>
>> >> > > > > >
>>  <flashplayerCommand>${flashPlayer.command}</flashplayerCommand>
>> >> > > > > >                                  </launcher>
>> >> > > > > >                                       </testRunner>
>> >> > > > > >                               </configuration>
>> >> > > > > >                       </plugin>
>> >> > > > > >               </plugins>
>> >> > > > > >       </build>
>> >>
>> >> > > > > > $ mvn test -DflashPlayer.command=c:/work/flashplayer.exe
>> >>
>> >> > > > > > the only way to get it working is putting the flashplayer on
>> the
>> >> > build
>> >> > > > > > folder.
>> >>
>> >> > > > > > On Aug 27, 10:49 am, Marvin Froeder <[email protected]>
>> wrote:
>> >> > > > > > > You could use like this:
>> >>
>> >> > > > > > > <build>
>> >> > > > > > >                <plugins>
>> >> > > > > > >                        <plugin>
>> >>
>> >> > > >  <groupId>org.sonatype.flexmojos</groupId>
>> >> > > > > > >                                <version>3.3.0</version>
>> >>
>> >> > > > > > >  <artifactId>flexmojos-maven-plugin</artifactId>
>> >> > > > > > >
>>  <extensions>true</extensions>
>> >> > > > > > >                                <configuration>
>> >> > > > > > >                                        <testRunner>
>> >> > > > > > >                                                <launcher>
>> >>
>> >> > > > > > >
>>  <flashplayerCommand>${flashPlayer.command}</flashplayerCommand>
>> >> > > > > > >                                   </launcher>
>> >> > > > > > >                                        </testRunner>
>> >> > > > > > >                                </configuration>
>> >> > > > > > >                        </plugin>
>> >> > > > > > >                </plugins>
>> >> > > > > > >        </build>
>> >>
>> >> > > > > > > For some reason maven is not injecting the flashplayer
>> command on
>> >> > > > > > component.
>> >>
>> >> > > > > > > VELO
>> >>
>> >> > > > > > > On Thu, Aug 27, 2009 at 10:42 AM, wlepinski <
>> [email protected]>
>> >> > > > wrote:
>> >>
>> >> > > > > > > > this also works for me. but is very impratical put
>> flashplayer
>> >> > on
>> >> > > > > > > > every flex project.
>> >>
>> >> > > > > > > > On Aug 27, 10:23 am, Brian <[email protected]> wrote:
>> >> > > > > > > > > We've also gotten this error when trying to set the
>> >> > flashplayer
>> >> > > > > > > > > command via a system variable.  The only work around we
>> found
>> >> > was
>> >> > > > > > > > > putting the flashplayer executable on the path for the
>> user
>> >> > > > running
>> >> > > > > > > > > the build.  We also found that allowHeadlessMode set to
>> false
>> >> > did
>> >> > > > not
>> >> > > > > > > > > work and xvfb-run still tried to spawn a process to
>> execute
>> >> > the
>> >> > > > test
>> >> > > > > > > > > runner; we were trying to use the xvnc plugin for
>> Hudson and
>> >> > we
>> >> > > > > > didn't
>> >> > > > > > > > > want to use xvfb.  In the end we switched over to xvfb
>> since
>> >> > we
>> >> > > > > > > > > couldn't turn it off.
>> >>
>> >> > > > > > > > > On Aug 27, 9:15 am, wlepinski <[email protected]>
>> wrote:
>> >>
>> >> > > > > > > > > > <build>
>> >> > > > > > > > > >                 <plugins>
>> >> > > > > > > > > >                         <plugin>
>> >>
>> >> > > > > > > > <groupId>org.sonatype.flexmojos</groupId>
>> >> > > > > > > > > >
>> <version>3.3.0</version>
>> >>
>> >> > > > > > > > <artifactId>flexmojos-maven-plugin</artifactId>
>> >>
>> >> > <extensions>true</extensions>
>> >> > > > > > > > > >                                 <configuration>
>> >> > > > > > > > > >                                         <testRunner>
>> >> > > > > > > > > >
>> <launcher>
>> >>
>> >> > > > > > > > <flashplayerCommand>flashplayer.exe</flashplayerCommand>
>> >> > > > > > > > > >
>> </launcher>
>> >> > > > > > > > > >                                         </testRunner>
>> >> > > > > > > > > >                                 </configuration>
>> >> > > > > > > > > >                         </plugin>
>> >> > > > > > > > > >                 </plugins>
>> >> > > > > > > > > >         </build>
>> >>
>> >> > > > > > > > > > i'm getting the same error.
>> >> > > > > > > > > > =(
>> >>
>> >> > > > > > > > > > On Aug 27, 9:59 am, Marvin Froeder <
>> [email protected]>
>> >> > wrote:
>> >>
>> >> > > > > > > > > > > Could you try the following configuration on
>> >> > pom:<testRunner>
>> >> > > > > > > > > > >   <launcher>
>> >> > > > > > > > > > >
>> <flashplayerCommand>yourCommand</flashplayerCommand>
>> >> > > > > > > > > > >   </launcher>
>> >> > > > > > > > > > > </testRunner>
>> >>
>> >> > > > > > > > > > > VELO
>> >>
>> >> > > > > > > > > > > On Thu, Aug 27, 2009 at 9:52 AM, wlepinski <
>> >> > [email protected]
>> >>
>> >> > > > > > wrote:
>> >>
>> >> > > > > > > > > > > > Running the following command
>> >> > > > > > > > > > > > $ mvn clean install
>> >> > > > > > -DflashPlayer.command=c:/work/flashplayer.exe
>> >>
>> >> > > > > > > > > > > > i'm getting...
>> >>
>> >> > > > > > > > > > > > [INFO]
>> >>
>> >> >
>> ------------------------------------------------------------------------
>> >> > > > > > > > > > > > [ERROR] BUILD ERROR
>> >> > > > > > > > > > > > [INFO]
>> >>
>> >> >
>> ------------------------------------------------------------------------
>> >> > > > > > > > > > > > [INFO] Failed to launch Flash Player.  Probably
>> java
>> >> > was
>> >> > > > not
>> >> > > > > > able
>> >> > > > > > > > to
>> >> > > > > > > > > > > > find flashplayer.
>> >> > > > > > > > > > > >                Make sure flashplayer is available
>> on
>> >> > PATH
>> >> > > > > > > > > > > >                or use
>> >> > -DflashPlayer.command=${flashplayer
>> >> > > > > > > > executable}
>> >> > > > > > > > > > > > Read more at:
>> >>
>> >> > > >https://docs.sonatype.org/display/FLEXMOJOS/Running+unit+tests
>> >>
>> >> > > > > > > > > > > > CreateProcess error=2, The system cannot find the
>> file
>> >> > > > > > specified
>> >> > > > > > > > > > > > [INFO]
>> >>
>> >> >
>> ------------------------------------------------------------------------
>> >> > > > > > > > > > > > [INFO] Trace
>> >> > > > > > > > > > > >
>> org.apache.maven.lifecycle.LifecycleExecutionException:
>> >> > > > Failed
>> >> > > > > > to
>> >> > > > > > > > > > > > launch Flash Player.  Pr
>> >> > > > > > > > > > > > obably java was not able to find flashplayer.
>> >> > > > > > > > > > > >                Make sure flashplayer is available
>> on
>> >> > PATH
>> >> > > > > > > > > > > >                or use
>> >> > -DflashPlayer.command=${flashplayer
>> >> > > > > > > > executable}
>> >> > > > > > > > > > > > Read more at:
>> >>
>> >> > > >https://docs.sonatype.org/display/FLEXMOJOS/Running+unit+tests
>> >> > > > > > > > > > > >        at
>> >>
>> >> > > > > >
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals
>> >> > > > > > > > > > > > (DefaultLifecyc
>> >> > > > > > > > > > > > leExecutor.java:703)
>> >> > > > > > > > > > > >        at
>> >>
>> >> >
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycl
>> >> > > > > > > > e
>> >> > > > > > > > > > > > (De
>> >> > > > > > > > > > > > faultLifecycleExecutor.java:540)
>> >> > > > > > > > > > > >        at
>> >>
>> >> > > > org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
>> >> > > > > > > > > > > > (DefaultLifecycl
>> >> > > > > > > > > > > > eExecutor.java:519)
>> >> > > > > > > > > > > >        at
>> >>
>> >> >
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFai
>> >> > > > > > > > lure
>> >> > > > > > > > > > > > s(DefaultLifecycleExecutor.java:371)
>> >> > > > > > > > > > > >        at
>> >>
>> >> > > >
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
>> >> > > > > > > > > > > > (Default
>> >> > > > > > > > > > > > LifecycleExecutor.java:332)
>> >> > > > > > > > > > > >        at
>> >> > > > > > > >
>> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
>> >> > > > > > > > > > > > (DefaultLifecycleExe
>> >> > > > > > > > > > > > cutor.java:181)
>> >> > > > > > > > > > > >        at
>> >> > > > > > > >
>> org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:
>> >> > > > > > > > > > > > 356)
>> >> > > > > > > > > > > >        at
>> >> > > > > > org.apache.maven.DefaultMaven.execute(DefaultMaven.java:
>> >> > > > > > > > > > > > 137)
>> >> > > > > > > > > > > >        at
>> >> > > > org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
>> >> > > > > > > > > > > >        at
>> >> > > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> >> > > > > > > > Method)
>> >> > > > > > > > > > > >        at
>> sun.reflect.NativeMethodAccessorImpl.invoke
>> >> > > > > > > > > > > > (NativeMethodAccessorImpl.java:39)
>> >> > > > > > > > > > > >        at
>> >> > sun.reflect.DelegatingMethodAccessorImpl.invoke
>> >> > > > > > > > > > > > (DelegatingMethodAccessorImpl.ja
>> >> > > > > > > > > > > > va:25)
>> >> > > > > > > > > > > >        at
>> >> > java.lang.reflect.Method.invoke(Method.java:597)
>> >> > > > > > > > > > > >        at
>> >> > org.codehaus.classworlds.Launcher.launchEnhanced
>> >> > > > > > > > > > > > (Launcher.java:315)
>> >> > > > > > > > > > > >        at
>> >> > > > > > > >
>> org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>> >> > > > > > > > > > > >        at
>> >>
>> >> ...
>> >>
>> >> read more ยป
>> > >
>> >
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Flex Mojos" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex-mojos?hl=en?hl=en

http://blog.flex-mojos.info/
-~----------~----~----~----~------~----~------~--~---

Reply via email to