如何在 Java 8 上使用 apple com.apple.eawt 功能? [英] How can I use apple com.apple.eawt functionality on Java 8?

查看:36
本文介绍了如何在 Java 8 上使用 apple com.apple.eawt 功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始学习 Java,我正在 Java IDE 上工作/改进.我正在尝试找到一种方法,以便当您双击一个文件时,该文件会自动使用我的程序打开.

I have recently started learning java and I am working/improving on a java IDE. I'm trying to find a way so that when you double click a file, the file is automatically opened with my program.

到目前为止,我发现的唯一方法是使用苹果扩展名 com.apple.eawt(问题找到 此处).唯一的问题是我有 JDK 1.8 并且此扩展不再有效.按照这个问题,我在我的电脑上寻找它,然后我相信它最后包含在 JDK 1.6 中.

So far the only way I have found to do that is by using the apple extension com.apple.eawt (question found here). The only problem is that I have JDK 1.8 and this extension no longer works. Following this question, I looked for it on my computer and I believe it was last included in JDK 1.6.

我的问题是:有没有办法在 java 1.8 中使用这个扩展?或者是否有 Apple 或非 Apple 替代品可以做到这一点?

My questions are: is there a way to use this extension in java 1.8? Or is there an Apple or non-Apple replacement that will do the same?

推荐答案

Java 9 复制了 java.awt.Desktop

例如,您指出了一个建议使用 Application.getApplication().setOpenFileHandler(myOpenHandeler) 的问题.

Java 9 has replicated most of com.apple.eawt in the java.awt.Desktop class

For instance, you pointed to a question that recommended using Application.getApplication().setOpenFileHandler(myOpenHandeler).

这相当于 Desktop.setOpenFileHandler(OpenFilesHandler openFileHandler).

此功能现在也可用于 macOS 以外的平台,例如 Windows.

This functionality is also now available on platforms other than macOS, such as Windows.

这篇关于如何在 Java 8 上使用 apple com.apple.eawt 功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆