Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Suggest Mac API method for launching applications?

Suggest Mac API method for launching applications?
Thread Tools
Fresh-Faced Recruit
Join Date: May 2001
Location: India
Status: Offline
Reply With Quote
May 25, 2001, 01:30 AM
 
hi,
I want to open any application based on the extension of the file through my java program. For example, if i have a abc.doc file then it must be launched in MS Word.
For this i have used native method (JNI approach) and used Window API method, ShellExecute(). Now i want the same thing using Mac API.

So can anyone tell me a Mac API method for doing the same.
Please help. Its urgent.

Thanx n Regds.
Rachna
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 25, 2001, 09:09 AM
 
Cocoa, I assume?

Use NSWorkspace's

public boolean openFile(
String fullPath,
String appName)
http://developer.apple.com/techpubs/...space/openFile

(I hope that's what you want)
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Rachna  (op)
Fresh-Faced Recruit
Join Date: May 2001
Location: India
Status: Offline
Reply With Quote
May 26, 2001, 04:27 AM
 
i have tried a program and used NSWorkSpace, openURL() method.
But its giving NoClassDefFoundException().

Program:

import com.apple.cocoa.application.*;
import java.net.*;
public class OpenFile
{
NSWorkSpace itsWSpace = new NSWorkSpace();
URL itsURL = null;
public OpenFile()
{
try
{
itsURL = new URL("www.google.com");
}catch(MalformedURLException e)
{
e.printStackTrace();
}
boolean result = itsWSpace.openURL(itsURL);
}
public static void main(String args[])
{
OpenFile aFile = new OpenFile();
}
}
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:14 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2