简体   繁体   中英

Java on OS X: How to provide operations in the Services menu (NSServices)

The goal is that a Java app provides contextual menu functions for files as seen in the Finder, thru the Services menu, on OS X 10.6 (Snow Leopard).

Is that possible from within Java code, or do I need to write a stub in ObjC which then talks to the Java app (via a socket)?

Any sample code around?

You won't be able add a Service to the Services menu using Java alone. There has to be a .service file in either /Library/Services/ or ~/Library/Services/ for your service to be registered with Finder.

You don't necessarily have to write it in Objective C. You can write a service using Apple Script if you find that easier.

An easy way to begin is writing an Automator Action that calls your Java application on the command line. You just choose "Save as Service" and it saves the .service file in your ~/Library/Services/ folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM