Problem executing an exe executable!

M

mohsen_fakhari

Hello
I'm trying to run a exe file named butil.exe from within a java
application.
This is my code:

Process p = run.exec("d:\\modec160\\p_21\\butil.exe");
BufferedReader err =new BufferedReader(new
InputStreamReader(p.getErrorStream()));
BufferedReader in = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}

while ((line = err.readLine()) != null) {
System.out.println(line);
}

int exitValue = p.waitFor();
System.out.println("Process exit value: " + exitValue);

exitValue is always 2.
Like many other programms 'butil' when run without any arguments will
give a usage discription,
but I don't have anything.
When I give its arguments,it should create a text file but I don't have
it too.
If it is important butil belongs to Btrieve,an old record manager and
I'm using JDK1.4 on winXP

Any thing you think may help,may really help.

Thank you.
 
R

Rhino

Hello
I'm trying to run a exe file named butil.exe from within a java
application.
This is my code:

Process p = run.exec("d:\\modec160\\p_21\\butil.exe");
BufferedReader err =new BufferedReader(new
InputStreamReader(p.getErrorStream()));
BufferedReader in = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}

while ((line = err.readLine()) != null) {
System.out.println(line);
}

int exitValue = p.waitFor();
System.out.println("Process exit value: " + exitValue);

exitValue is always 2.
Like many other programms 'butil' when run without any arguments will
give a usage discription,
but I don't have anything.
When I give its arguments,it should create a text file but I don't have
it too.
If it is important butil belongs to Btrieve,an old record manager and
I'm using JDK1.4 on winXP

Any thing you think may help,may really help.

Thank you.

Return code 2 on Windows means that the file 'd:\\modec160\\p_21\\butil.exe'
does not exist. Perhaps you've just mistyped the path? By the way, here's a
link to the full set of Windows return codes:
http://msdn.microsoft.com/library/?url=/library/en-us/debug/base/system_error_codes.asp?frame=true

Also, I found this article very useful in helping me with problems in
running executables:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html.
 
M

mohsen_fakhari

Hi
I think there should be another missed file,because the path is correct
and
when I change the path to an incorrect path(e.g. buti.exe instead of
butil.exe)
I got another error:
java.io.IOException: CreateProcess: d:\modec160\p_21\buti.exe error=2

Thank you
 
M

mohsen_fakhari

I read the document in JavaWorld too.
It was helpfull and I know a lot more now,
but there it didn't help me
 
N

nelsonsoft

If the error is from Butil then the error 2 could represent a corrupt
btrieve file. Do you get this error from just running the command line
utility by itself.

Gil
 
M

mohsen_fakhari

Running butil in cmd I have such a thing:
Btrieve Utilities Version 5.12
Copyright 1982 - 1990, Novell, Inc. All Rights Reserved.
Usage is BUTIL -CLONE <OUTPUT-FILE> <SOURCE-FILE> [-O<OWNER1>]
Usage is BUTIL -COPY <INPUT-FILE> <OUTPUT-FILE> [-O<OWNER1>
[-O<OWNER2>]]
Usage is BUTIL -CREATE <FILE-NAME> <DESCRIPTION FILE>
Usage is BUTIL -DROP <BTRIEVE-FILE> <KEY NUMBER> [-O<OWNER>]
....

But from within my java code I receive nothing
 
M

mohsen_fakhari

Hi all
If it may help:
I created a bat file with instructions to run butil and then
tried to run this bat file from within my java code.
Surprisingly it works!
I've error messages I should and whith correct arguments I've correct
resulted files.

I'm still eager to do it by pure java.

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top