|
|
Problems opening Wordpad from java (but notepad works just fine....)
Hi All,
I'm attempting to open wordpad on a file I've just created.
I can open notepad on it just fine, but wordpad causes;
Error java.io.IOException: CreateProcess: wordpad
C:\TEMP\my_file.txt error=2
I call this process 3 times ('cos I have 3 files I want to display). The
3 notepad windows open up fine, but the 3 wordpad invocations fail ?
public void show(String fileName) {
Runtime rt = Runtime.getRuntime();
String command1, command2;
command1 = "notepad " + fileName;
command2 = "wordpad " + fileName;
try {
Process p1 = rt.exec(command1);
Process p2 = rt.exec(command2);
} catch (Exception e) {
System.out.println("Error " + e);
}
(I put the notepad & wordpad invocations in together hoping to spot any
typos. Just calling wordpad on its own still fails.)
If I 'run' the command;
wordpad C:\TEMP\my_file.txt - the window opens up fine
I've tried the file name with & without quotes but no difference.
Any ideas
TIA
Bill
}
}
|
|
0
|
|
|
|
Reply
|
wfs4 (3)
|
10/15/2006 12:58:52 PM |
|
Bill wrote:
> Hi All,
> I'm attempting to open wordpad on a file I've just created.
>
> I can open notepad on it just fine, but wordpad causes;
>
> Error java.io.IOException: CreateProcess: wordpad
> C:\TEMP\my_file.txt error=2
Perhaps this command line output might shed some
light on the matter..
C:\Documents and Settings\Administrator>notepad
C:\Documents and Settings\Administrator>wordpad
'wordpad' is not recognized as an internal or external command,
operable program or batch file.
& BTW - did I miss the connection with graphical user interfaces?
This type of question is best dealt with on a group such
as comp.lang.java.programmer
Andrew T.
|
|
0
|
|
|
|
Reply
|
Andrew
|
10/15/2006 1:50:49 PM
|
|
Hi Andrew,
thanks for the help.
This appears to work.
public void show(String fileName) {
Runtime rt = Runtime.getRuntime();
String command1, command2;
command1 = "notepad " + fileName;
command2 = "C:\\Progra~1\\Window~1\\Access~1\\wordpad.exe " +
fileName;
try {
Process p1 = rt.exec(command1);
Process p2 = rt.exec(command2);
} catch (Exception e) {
System.out.println("Error " + e);
}
}
Bill
- we'll it is called from a Swing app.....
"Andrew Thompson" <andrewthommo@gmail.com> wrote in message
news:1160920248.986201.309770@m7g2000cwm.googlegroups.com...
> Bill wrote:
>> Hi All,
>> I'm attempting to open wordpad on a file I've just created.
>>
>> I can open notepad on it just fine, but wordpad causes;
>>
>> Error java.io.IOException: CreateProcess: wordpad
>> C:\TEMP\my_file.txt error=2
>
> Perhaps this command line output might shed some
> light on the matter..
>
> C:\Documents and Settings\Administrator>notepad
>
> C:\Documents and Settings\Administrator>wordpad
> 'wordpad' is not recognized as an internal or external command,
> operable program or batch file.
>
> & BTW - did I miss the connection with graphical user interfaces?
> This type of question is best dealt with on a group such
> as comp.lang.java.programmer
>
> Andrew T.
>
|
|
0
|
|
|
|
Reply
|
Bill
|
10/15/2006 3:12:21 PM
|
|
Bill wrote:
> Hi Andrew,
> thanks for the help.
Your future lack of top-posting, will be thanks enough.
> This appears to work.
Glad you sorted it.
> > & BTW - did I miss the connection with graphical user interfaces?
> > This type of question is best dealt with on a group such
> > as comp.lang.java.programmer
...
> - we'll it is called from a Swing app.....
Sure. But if you can produce the error with no GUI involved
(which you could with your original code, by wrapping it in
a few lines and adding a main()), it is a good sign it is not
a topic best suited to this group. ;-)
Andrew T.
|
|
0
|
|
|
|
Reply
|
Andrew
|
10/15/2006 3:46:35 PM
|
|
|
3 Replies
252 Views
(page loaded in 0.035 seconds)
|
|
|
|
|
|
|
|
|