Hi,

I have checked on this a bit further and there is a JDK bug in 1.3.1-b24
(maybe only on Win2k) which causes the ant problem. The issue is that
Process exec(String command, String[] env) should follow its documented
behaviour...

If envp is null, the subprocess inherits the environment settings of the
current process

But a simple test shows that Path is not inherited (latex is in Path)
and cannot even be explicitely passed. I had a look on the Sun Bug
Parade but couldn't see anything.

e.g. None of below work except number one which uses fully qualified
path.

import java.io.*;

public class MyTest 
{
    public static void main(String[] args)
    {
        //try to start latex
        Runtime run = Runtime.getRuntime();
                try
                {
                        run.exec("c:\\program
files\\miktex\\miktex\\bin\\latex.exe d:\\test.tex", null);
                        System.out.println("First test complete");
        }
                catch(IOException ex)
                {
                        System.out.println("First test failed : " + ex);
                }
                try
                {
                        run.exec("latex d:\\test.tex", null);
                        System.out.println("Second test complete");
        }
                catch(IOException ex)
                {
                        System.out.println("Second test failed : " +
ex);
                }
                String[] env = new String[] { "Path=\"c:\\program
files\\miktex\\miktex\\bin\"" };
                try
                {
                        run.exec("latex d:\\test.tex", env);
                        System.out.println("Third test complete");
        }
                catch(IOException ex)
                {
                        System.out.println("Third test failed : " + ex);
                }
                String[] env2 = new String[] { "PATH=\"c:\\program
files\\miktex\\miktex\\bin\"" };
                try
                {
                        run.exec("latex d:\\test.tex", env2);
                        System.out.println("Fourth test complete");
        }
                catch(IOException ex)
                {
                        System.out.println("Fourth test failed : " +
ex);
                }
    }
} 

-----Original Message-----
From: Bernd Gruendling [mailto:[EMAIL PROTECTED]]
Sent: 10 July 2001 12:36
To: [EMAIL PROTECTED]
Subject: Re: Environment not being passed to Apply task command (I
think) - Win2k


Alex,

did you solve this problem? I get exactly the same error when trying 
to run a batch file with <exec>. The batch file is fine, of course.

Bern.d


>
>
>and I get...
>
>D:\Project\ant\build.xml:458: Execute failed: java.io.IOException:
>CreateProcess: latex D:\Project\doc\design\SomeDoc.tex error=2
>--- Nested Exception ---
>java.io.IOException: CreateProcess: latex
>D:\Project\doc\design\SomeDoc.tex error=2
>        at java.lang.Win32Process.create(Native Method)
>        at java.lang.Win32Process.<init>(Win32Process.java:66)
  ...

_______________________________________________________________________
Bernd Gruendling                            Custom Software Development
Systemberatung Softwaredesign                    for Mac OS and Windows

Wendenstrasse 16                                Phone: +49 5363 97676-0
38448 Wolfsburg, Germany                    Facsimile: +49 5363 97676-9

Reply via email to