The Artima Developer Community
Sponsored Link

Java Answers Forum
Execute the file

3 replies on 1 page. Most recent reply: Mar 18, 2002 6:38 PM by Matt Gerrans

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 3 replies on 1 page
Bob Sunder

Posts: 3
Nickname: tp20191
Registered: Mar, 2002

Execute the file Posted: Mar 17, 2002 10:28 AM
Reply to this message Reply
Advertisement
How do I execute the file using JAVA code. Here is what I am doing... I am transferring the file from machine A to machine B, after the transfer is complete, I would like to open.execute the file. I assume it will use the appropriate application to open/run/execute the file. (ie. Notepad for .txt file, real player for .ram files etc.)


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Execute the file Posted: Mar 17, 2002 1:25 PM
Reply to this message Reply
First, do didn't say what platform you are talking about and this is a very platform-specific question, but I'll assume it is Windows, based on what you've said.

If you want to be able to run class or jar files by double-clicking them, you need to set up an association for them in Explorer. However this is a mess, because Java wants the class file specified without the extension (one would think they would be smart enough to handle both! How hard is it to either strip or add ".class" from a specified class or file name?), whereas Explorer will pass the full file name. However, there is a detailed explanation of how to set this up in Artima's legacy Java Answers Forum. If you can't find it, report back here and we'll add it to this forum. The jar file is a little easer to handle and that is also covered in a previous post, so the follow the same procedure with it.

Also keep in mind that the association can be changed when you install some application that thinks it is the best choice for handling these files. For instanace, after I installed JBuilder, it appropriated the class file association.

Bob Sunder

Posts: 3
Nickname: tp20191
Registered: Mar, 2002

Re: Execute the file Posted: Mar 18, 2002 8:20 AM
Reply to this message Reply
It is windows platform.
I don't need to execute .class file. I want to run/execute/open the file (.txt, .ram, .mp3) that I transfers to the client machine. And I want to open/play it there.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Execute the file Posted: Mar 18, 2002 6:38 PM
Reply to this message Reply
Ah, this too, was covered in a previous post. Search for "rundll" and Runtime.exec(). I think you will need to search the lagacy forums.

Flat View: This topic has 3 replies on 1 page
Topic: Parameters in Java Previous Topic   Next Topic Topic: Object and Image Classes

Sponsored Links



Google
  Web Artima.com   

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