File Won't Run with Runtime On Windows XP



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?

Thanks!

Hal
.



Relevant Pages

  • Re: Different behaviour reading static field Windows vs Linux
    ... java -cp classes com.sun.star.lib.loader.Loader test.Main ... Note that the first command only works under Linux (i.e. it ... for Linux and is supplied as part of the OpenOffice SDK. ...
    (comp.lang.java.programmer)
  • Re: File Wont Run with Runtime On Windows XP
    ... my program uses a script to run programs. ... I have a DOS .bat file that runs OpenOffice on Windows XP. ... Java, the file runs but it doesn't run OpenOffice. ... I figure there must be something different about the environment within the ...
    (comp.lang.java.programmer)
  • Re: Why Are There No Killer Java Apps ?
    ... >> Four apps written in Java that I couldn't live without right there. ... > OpenOffice isn't written in Java. ... Matt believes these newsgroups are populated by mostly ... written in other languages implies the main program ...
    (microsoft.public.dotnet.general)
  • Re: [SLE] Complete Switch
    ... Java won't be a problem. ... There are some BASIC's in Linux, ... StarBasic in the openoffice suite, but would Python, for example, fit ... Check with Sun. ...
    (SuSE)
  • Re: MYsql OpenOffice
    ... OpenOffice, as well as the "ODBC/JDBC bridge." ... the 1.5 version of Java. ... especially if the ClassPath is set. ... My only excuse is that I have installed and dis-installed systems so often ...
    (alt.os.linux.suse)