Re: File Won't Run with Runtime On Windows XP
- From: Martin Gregorie <martin@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 02 Sep 2007 19:48:06 +0100
Hal Vaughan wrote:
I have a program that uses OpenOffice and the associated classes. This isTry 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.
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?
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
.
- References:
- File Won't Run with Runtime On Windows XP
- From: Hal Vaughan
- File Won't Run with Runtime On Windows XP
- Prev by Date: Re: dependency-detection in java - Take 2
- Next by Date: Re: dependency-detection in java - Take 2
- Previous by thread: File Won't Run with Runtime On Windows XP
- Next by thread: Re: File Won't Run with Runtime On Windows XP
- Index(es):
Relevant Pages
|