• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

running another application from java

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you run a batch file? If so what would the path look like?
Steve
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean call to exec()
 
reply
    Bookmark Topic Watch Topic
  • New Topic