Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Problem executing an exe executable!

Thread view: 
mohsen_fakhari@yahoo.com - 09 Nov 2006 07:59 GMT
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.
Rhino - 09 Nov 2006 13:58 GMT
> Hello
> I'm trying to run a exe file named butil.exe from within a java
[quoted text clipped - 30 lines]
>
> 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_co
des.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.

--
Rhino
mohsen_fakhari@yahoo.com - 09 Nov 2006 15:09 GMT
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
mohsen_fakhari@yahoo.com - 09 Nov 2006 15:22 GMT
I read the document in JavaWorld too.
It was helpfull and I know a lot more now,
but there it didn't help me
nelsonsoft@nssdd.com - 09 Nov 2006 16:36 GMT
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

> I read the document in JavaWorld too.
> It was helpfull and I know a lot more now,
> but there it didn't help me
mohsen_fakhari@yahoo.com - 09 Nov 2006 17:00 GMT
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
mohsen_fakhari@yahoo.com - 09 Nov 2006 17:40 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.