将 Java 程序添加到 Ubuntu 上下文菜单
我正在开发一个与 Ubuntu 一起使用的 Java 桌面应用程序。我需要添加一个上下文菜单项,当用户右键单击文件时出现该菜单项,并将完全限定的文件路径作为参数传递给程序。
搜索后我发现我可以使用Nautilus-Actions,但我想分发我的软件。因此,它应该是一个 shell 脚本或安装选项。
我该如何实现这一目标?
I'm developing a Java desktop application that is to be used with Ubuntu. I need to add a context menu item which appears when the user right clicks on a file and to pass the fully qualified file path as an argument to the program.
After searching I found I can use Nautilus-Actions but I want to distribute my software. Therefore, it should be a shell script or installation option.
How do I achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
部署应用程序。使用 Java Web Start 并对应用程序的文件类型感兴趣。可以使用 JNLPassociation 元素处理(例如 .txt、.rtf、.html) > (应用程序启动)文件。
有关在 JWS 应用程序中使用文件关联的示例,请参阅文件服务演示。 我的 JNLP API 演示。
Deploy the app. using Java Web Start and register an interest in the types of files the app. can process (e.g. .txt, .rtf, .html) using an
association
element in the JNLP (app. launch) file.For an example of using file associations in a JWS app., see the file service demo. of my JNLP API demos.
您可以从命令行和脚本使用 nautilus-actions:
但是,这需要安装此软件包(我使用的是 Ubuntu Oneiric Alpha,但未安装此软件包),这只能通过将程序打包为 deb 来实现档案。
其他可能性是 Nautilus 脚本,它不需要任何软件包。但它会将您的菜单项放在子菜单中。
像 nautilus-open-terminal 这样的程序可以在没有任何依赖的情况下向 nautilus 菜单添加内容,您可能需要查看其源代码。
You can use nautilus-actions from command line and script:
However, this requires for this package to be installed (I'm using Ubuntu Oneiric Alpha and this package was not installed), which can only be acheived by packing your program as a deb archive.
Other possibility is Nautilus Scripts which does not require any packages. But it will place your menu item in a submenu.
Programs like nautilus-open-terminal add stuff to the nautilus menu without any dependencies, you might want to checkout its source.