This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running another application from java

 
cs sakthi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried running an exe file from java application using the class Runtime like
class Notepad
{
public static void main(String arg[])
{
try
{
Runtime r = Runtime.getRuntime();
r.exec("C:\\Winnt\\NOTEPAD.EXE");
}
catch(Exception e) {}
}
}
in a Windows NT machine. While running it, it works fine and the application Notepad.exe is opened.
My doubt is that is it possible to open a particular file like
class open
{
public static void main(String arg[])
{
try
{
Runtime r = Runtime.getRuntime();
r.exec("S:\\java-21\\ar.pdf");
}
catch(Exception e) {}
}
}
when i run this nothing is opened and no runtime error is comming. please clear this (with code if possible).
Thanks,
Sakthi.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't actually execute a pdf file. I think that you want to execute Acrobat.exe with the pdf file as an input parameter.
 
Amit Chawla
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, you cant run a PDF file from JVM, because the JVM does not understand Windows file assciciations....
Modify your code as follows:
try {
Runtime.getRuntime().exec("C:\\Program Files\\Adobe\\Acrobat 4.0\\Reader\\AcroRd32 S:\\java-21\\ar.pdf");
}
catch(Exception e) {
e.printStackTrace();
}
[This message has been edited by Amit Chawla (edited May 17, 2001).]
 
steve dowdall
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you run a batch file? If so what would the path look like?
Steve
 
Umesh Joglekar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to simulate the action of windows using the correct apllication to open a given file type when you double click on a file then you really need to find the file association from the registry (assuming you are writing this just for the windows platform) and use the appropriate application in the call to execute()
 
Umesh Joglekar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean call to exec()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic