Re: downloading then running a uncommon file type on a mac



In article <1152644482.241265.94540@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"javajavalink" <link9404@xxxxxxxxx> wrote:

I need help with a program that will be run on mac OS X (with java
installed). The program has to download a file (not a common file type)
from a specific spot on aserver(running windows) to the desktop of the
mac. Then it has to open the file (as if you doulbe clicked it).

I am a relatively new to java. I know basic networking (i made a
chatroom program) and a bit about the regular stuff. I uses the sun
information (java.sun.com/j2se/1.5.0/docs/... alot so any refrences to
that would be helpful.

Here is what i don't know how to do (if it is possible in java):
-download a file from a server (is there a method for this that i can
use after i open the socket?)
-save this file to the desktop (this has to be done on a bunch of
different macs so i wont know their username or anything like that)
-launch the file (is there a program i can run on the file? like if is
was a MS word file, is there a program inside MS word that i could call
on the file?)

Thanks in advance!

When you say "with Java installed" in reference to Mac OS X, it's kind
of redundant. Every copy of Mac OS X ever shipped has had Java
installed since its initial release in March 2001. Which version is
available, however, is a different matter. I don't know off the top if
10.3 systems have access to a Java 1.5 release or not. And 10.4 systems
do not have it installed by default. You might want to keep that in
mind.

I'll leave the networking for someone else to offer suggestions except
to say that it won't matter that the program is on a Mac.

As for the "desktop" question, that could depend on the language
setting. Mac OS X is build on a foundation that derives from BSD, so
it's got a *nix-style filesystem. Ordinarily, user home directories are
located in /Users, but you shouldn't rely on that. And the user's
desktop is represented by a directory named "Desktop" on US English
systems, but it may be named something else entirely in other language
settings. You'll find the Javadocs for Apple's extensions to Java at
<http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/a
pi/index.html>. Take a look at the com.apple.eio.FileManager class
there. You probably need to use one of the static findFolder methods
there to do it safely. The trouble is, I'm having trouble locating a
clear idea what values you would need for domain (where you would
indicate the "user domain") and folderType (where you would indicate the
"desktop folder"). I'm only now beginning to delve into Mac-specific
issues for my own purposes, and I haven't figured that part out yet.

As for launching the file, you could take a relatively simple approach
and do something based on the Runtime.exec method. If you're familiar
with Windows, you know that you can use exec to "start" a file and let
Windows automatically hand it over to whatever app (if any) is
associated with its extension. Mac OS X doesn't rely entirely on
extensions, but you can do a similar trick there using the "open"
command. If you have access to a Mac OS X system, use its Terminal
application to get to a command line and try "man open" to read more.
Basically, though, the command "open file" (where file could also be a
URL, even a file: type URL) will open the file or URL with whatever
program the user has set for it. The man page will point out various
options for open.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
.



Relevant Pages

  • Re: 10 Reasons .NET developers should consider the switch to Mac OS
    ... Core 2 Duo based Mac? ... Java on Windows is just as much a "jewel" as it is on the Mac. ... Frankly, if Apple were charging for Xcode, I'd be offended. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: More chords than you can shake a plectrum at
    ... I got someone to provide me with the Mac starter app, as I am on Windows at ... It runs for me on my OS X 10.4 Mac. ... but I'm pretty sure it would work as it's vanilla Java code with no OS ...
    (rec.music.makers.guitar.acoustic)
  • Re: Should I buy an Apple or Windows
    ... Windows have its own issues. ... Programming in Perl on OS X is pretty much identical to using any other ... Java on OS X is fair-to-good these days. ... Oracle 10g is certified on the Mac for all your Oracle needs. ...
    (comp.sys.mac.advocacy)
  • Re: Windows doesnt do that
    ... crafted Java applet. ... through Java as Java's applets can run without permission from a ... Because there are virus protection products for the Mac and apps ... protect our windows buddies from getting a windows malware from ...
    (comp.sys.mac.advocacy)
  • Re: Swing on Mac
    ... >> a windows or linux machine. ... I work mainly on the Mac, ... another serious issue relates to the language kits, in java you are supposed ...
    (comp.lang.java.programmer)