Re: File Won't Run with Runtime On Windows XP



Hal Vaughan wrote:
I have a program that uses OpenOffice and the associated classes. This is
not an OpenOffice problem, but a strange problem of trying to run a
program. For several reasons, my program uses a script to run programs. This lets me set arguments in the script (with some programs, others don't
need it) and it makes it a bit easier to keep track of paths across
different platforms.

I have a DOS .bat file that runs OpenOffice on Windows XP. I've never had a
problem with it in several years. If I run it from the command line, I can
see it's working just fine. But if I run that same .bat file from within
Java, the file runs but it doesn't run OpenOffice. Here's the .bat file:

SET ooo_file=$ooo_dir\program\soffice
if "%1" == "" "%ooo_file%" -quickstart >nul
if "%1" == "-quickstart" "%ooo_file%" -quickstart >nul
if "%1" == "-headless" "%ooo_file%" -headless >nul

Which I shortened, while testing, to this:

SET ooo_file=$ooo_dir\program\soffice
"%ooo_file%" -quickstart >nul

As I said, it works just fine (in either version) from the command line. Then I run it in Java, using this:

try {
Runtime.getRuntime().exec(sFile);
} catch (Exception e) {
sysConfig.log("error", "Cannot Run Command (RunFile): " + sFile + ",
Error: " + e);
TNConfig.printTrace(e);
}

While the functions in the error trapping section are my own, they're not
the issue and when I'm having problems, they're never used, so no error is
thrown when I try this.

I've used this setup, on Windows XP, for a few years and there hasn't been a
problem. Now when I use it, the script works fine from the command line. I know it is being run from within Java. I changed the ">nul" to redirect
to a file, the file was created but was empty. (There is no output from
OpenOffice normally, so I didn't expect output.) That tells me Java is
running the batch file and, supposedly, running OpenOffice, but the program
just isn't running (or is running quickly and exits).

Previously I had used Java 1.4.2 or Java 5, but this system is running Java
6. I've tested this on another XP system using Java 6 and I don't have
this problem.

I figure there must be something different about the environment within the
Runtime.getRuntime().exec() environment that a program can detect that
varies from the command line. It might also be likely that this change is
in Java 6 but not in earlier versions.

Can anyone shed some light on this problem?

Try running a test script that displays the environment variables rather than trying to run Open Office etc and see what the differences are between what it shows in good and bad environments.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
.



Relevant Pages

  • Re: Why PHP is so succesfull?
    ... Trent> sounds like a lot of hassle to me. ... I've never written CGI scripts with Java myself. ... copying my first Hello World CGI java script to your ...
    (comp.programming)
  • Re: image gallery
    ... Does this mean i dont have to modify the second part of the script - telling ... If your pictures are stored in your images folder, ... pictures like the FP Banner web component but will be visible to users ... Being in Java doesn't usually / neccessarily mean insecure. ...
    (microsoft.public.frontpage.addins)
  • Re: [opensuse] Editting PATH variable
    ... SuSEconfig script ... ... not knowing what you options you used to install ... If your unfamiliar with Bash a good book is 'Learning the Bash Shell' by ... For Java use editing the PATH variable is NOT required... ...
    (SuSE)
  • Re: JAvascripts not working in my computer
    ... I have all my java enabled in the ... >> Script Debugging Problem ... >> Sun JRE.) ... >> Sun also offers an automatic download and install of the 1.4 Java ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: file not found or server unavailable web site links
    ... and definely looks like a virus writter script deletion ... >> There is an apparent java script error with IE6. ... the Sun JRE.) ... >Sun also offers an automatic download and install of the ...
    (microsoft.public.windows.inetexplorer.ie6.browser)