The Artima Developer Community
Sponsored Link

Java Answers Forum
System Shell in a Java Application

5 replies on 1 page. Most recent reply: Aug 19, 2002 4:08 AM by Lucio

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Lucio

Posts: 14
Nickname: luzzy00
Registered: Jul, 2002

System Shell in a Java Application Posted: Jul 25, 2002 6:31 AM
Reply to this message Reply
Advertisement
Hello,
I need to open an image (.jpg),with the standard program of the operative system.
How can I do?


Don Hill

Posts: 70
Nickname: ssswdon
Registered: Jul, 2002

Re: System Shell in a Java Application Posted: Jul 25, 2002 7:08 AM
Reply to this message Reply
Take a look at the Runtime class, I believe that you will need to call Runtime.exec();

Lucio

Posts: 14
Nickname: luzzy00
Registered: Jul, 2002

Re: System Shell in a Java Application Posted: Jul 26, 2002 4:08 AM
Reply to this message Reply
I have read about the class Runtime, but I don't understand how I can use this class.
Can you show me a simple example,please?
thank you

Lucio

Posts: 14
Nickname: luzzy00
Registered: Jul, 2002

Re: System Shell in a Java Application Posted: Jul 26, 2002 4:37 AM
Reply to this message Reply
I have write so:
try{
String[] cmdLine = {"open", "c:/test.jpg"};
Process a=Runtime.getRuntime().exec(cmdLine);
}catch(Exception e)
{}

It gives me a createProcess error, probabily because it
is not a command.com istruction.
I'd like to have an universal command to open the image with the default program.

thank you

Don Hill

Posts: 70
Nickname: ssswdon
Registered: Jul, 2002

Re: System Shell in a Java Application Posted: Jul 26, 2002 6:06 AM
Reply to this message Reply
Try the command "start" for example at the command prompt if I type start some.jpg it will open my jpg in the app associatted with jpg.

HTH

Lucio

Posts: 14
Nickname: luzzy00
Registered: Jul, 2002

Re: System Shell in a Java Application Posted: Aug 19, 2002 4:08 AM
Reply to this message Reply
Thank you very much.

ps:I have tried on "Win", and I hope that my program go on "Mac Os" too.

Flat View: This topic has 5 replies on 1 page
Topic: Disabling PrintScreen Previous Topic   Next Topic Topic: Convert Java program into C program

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use