Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime.exec() works some of the time

Status
Not open for further replies.

acent

Technical User
Feb 17, 2006
247
US
I am working on an update program to keep my database front ends updated on the users computer. This program looks at the server, and compares 2 files, then copys the server file to the users computer if update is needed.
Finally, the program opens the database file.

The program works great up to the point of opening the database front end file- it only happens some of the time. My code for this:
Code:
Process p = Runtime.getRuntime().exec("cmd /c start C:/dbfe/po_fe.mde");

I have spent soem time searching this forum for the answer, but can't make heads or tails of it all. I have tried changing it to, but Access wouldn't open the MDE correctly:
Code:
Process p = Runtime.getRuntime().exec("c:/program files/microsoft office/office11/msaccess.exe C:/dbfe/po_fe.mde");

Any ideas why these solutions don't work or only work some of the time?

Thnaks

"God is a comedian playing to an audience too afraid to laugh."
-- Francois Marie Arouet (Voltaire)
 
For the first line of your code, I have tried. but I don't know if you have given a correct database name. I think the extention of an Access Db is 'mdb' not 'mde'.

if you change that, I think it will work.

Code:
Process p = Runtime.getRuntime().exec("cmd /c start C:/dbfe/po_fe.mdb");

Chinese Java Faq Forum
 
Wangdong, an mde is a 'compiled' version of the Access Database such that the code in it cannot be altered. I'd have thought it would be fine. Besides, he said that it works 'some of the time' so there must be something more subtle at work.

Tim
 
Thanks for the replys.

Sedj, There are no errors. The program completes normally. I tried to catch an ioexception, but again nothing.
Code:
try {
   Process p = Runtime.getRuntime().exec("cmd /c start C:/dbfe/po_fe.mde");
} catch (IOException e) {
      System.out.println(e.getMessage());
}

Is there another exception that is thrown in the background? Or a better way to execute a file?

Thanks

"God is a comedian playing to an audience too afraid to laugh."
-- Francois Marie Arouet (Voltaire)
 
Whats happens if you do :

Process p = Runtime.getRuntime().exec("cmd /c start C:/dbfe/po_fe.mde");
p.waitFor();

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Sedj, still nothing. I did however notice that after the file is copied from the server, it leavs a po_fe.ldb showing po_fe.ldb did not close. Would it help if I put my complete program here?

Thanks

"God is a comedian playing to an audience too afraid to laugh."
-- Francois Marie Arouet (Voltaire)
 
For those of you experiencing the problem, I solved it by closing the connections to the databases. Now the program works everytime.



"If you say you can, or you say you can't, you're right!"
-- Henry Ford
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top