Locating installed application

stolmax

Registered
Is there a way to locate an already installed application on Mac OSx. I need to do it programmatically, from Java. Java by itself will not do it for you. I know I can probably do it using a shell command with the help of Runtime.getRuntime().exec(), but I would rather do it by calling a set of existing Mac OS X/9 APIs. Thanks in advance.
 
One option would be to use the shell command "which". Type "which <executablename>" and if the executable is in the system's search paths, you will get a path to the file.

As for an API call... I'm sure it's doable but perhaps not with a single call. Dunno off the top of my head.
 
Thanks, if you ever have a moment to figure the API calls to this or will come across it please let me know. Thanks in advance.
 
I stumbled upon this last night:

You'll have to use Cocoa though, there's a class called NSWorkspace that'll let you do neat things, including get names of apps installed I think. Check develop.apple.com specifically the Cocoa reference and lookup NSWorkspace. I'm using it to get the icon image of any particular file.
 
Actually, never mind. I need to do it Java. What was I thinking... Thanks. How do you write a demon application in C on Mac, should I write it using Project Builder in Carbon???? The main thing, is I don't want to have terminal window displayed.
 
Thanks, I know that I can write Java code using Cocoa, what I don't know is how to write a console application using C that will work like demon on the user's machine; the main thing is this application should be started as other GUI application, except that it should not display the gui, do some quick processing and then launch another application. I don't want the terminal window displayed. Thanks
 
Well, for what it's worth: I've written several Objective C programs in cocoa, and even added printf statements to them as a debugging tactic. If I run them in ProjectBuilder, this output appears in PB's "run" window. However, if I compile them & run them outside of Project Builder, I do NOT get a terminal window, even if I leave the printf's in. The output apparently just falls into a black hole.

I haven't tried writing Cocoa/Java, but I would assume the behavior is similar.

The only circumstance I know of in which a terminal window *will* open on its own is if you add the .command extension to a shell script and double click it.
 
That' sounds good. I am struggling to get development tools installed on my machine right now, but as soon as I get them installed I'll definitely try your suggestion. If I develope application in cocoa, can they run on MacOS9? And when you say, developed in Cocoa do you mean you developed them using Project Builder? Thanks, I am still sorting varios development environments.
 
Cocoa is a development framework, which I am afraid is exclusive to OSX. You can access it from either Java or Objective C, but it's functionality is rooted in OS X. Sorry!

Java code (without the cocoa framework) *can* of course be compiled and executed in OS9, but I'm afraid my OS9/Java skills are minimal. Apple does offer the "MRJ SDK" (Mac Runtime for Java Software Developer's Kit) for OS9 on their development website, and it includes utilities for compiling Java code and linking it into an executable. I cannot, however, advise you on how to find the path to an application in OS9.

Best of luck.

PS: I can, howver, assure you that you will *never* get a terminal session in OS9!! :)
 
I think I PMed you or someone else, or posted this somewhere.

In *nix OSes, console apps will just execute and never open a terminal window. This works for you, but some people (like me) wants a terminal window opened.
 
BTW thanks for answering all of my questions. What should I use to develop applications that run both on MacOS X and 9. (Not Java). Can I use Project Builder for that? Like you can tell, I don't have developement toold yet installed on my computer, for some reason I could not download them from apple's web site, so I ordered them but was not told when I will actually receive them. Thanks again.

Thanks
 
If you use Project Builder and develop in Carbon (a different framework from cocoa) you can make Mac-only apps that will run in either OS9 or OSX. Carbon is strictly C/C++ based - not java. Carbon is also significantly more complex to code with than Cocoa, but if you need to create a single app that runs on both OSX and OS9, it's probably the best way to go.

I am not aware of a way to make a single binary application file, written in Java, that will run on both platforms without modification. That doesn't mean there IS no way, but I don't know what it is.

Best of luck!
 
Back
Top