为什么NetBeans在OS X上运行我的程序,而不是将其构建到JAR中? [英] Why is NetBeans running my program on OS X, but not building it into a JAR?

查看:106
本文介绍了为什么NetBeans在OS X上运行我的程序,而不是将其构建到JAR中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tl; dr



我错过了哪些依赖项允许NetBeans在内部运行OS X集成程序,但不是能够清理并构建它到JAR?






我正在尝试制作一个集成到OS中的Java程序X,但我希望将它发布到Windows和Linux上。为此,我使用 com.apple.eawt 包的实用程序类。



到目前为止,它是太棒了我已将我的菜单栏集成到OS X中,我有首选项处理程序和关于处理程序以及所有有趣的东西,并且它工作得很好...当我在NetBeans中单击运行时。然而!当我点击清理和构建时,我会收到许多这样的错误:

  / my / source / path / MenuBarManager.java:3:错误:包com.apple.eawt不存在
import com.apple.eawt.AboutHandler;
/my/source/path/MenuBarManager.java:62:错误:找不到符号
私有静态类MyAboutHandler实现AboutHandler {
^
符号:class AboutHandler
location:class MyMenuBarManager
/my/source/path/MyMenuBarManager.java:68:error:package AppEvent不存在
@Override public void handleAbout(AppEvent.AboutEvent ae){
^
/my/source/path/MyMenuBarManager.java:67:错误:方法不会覆盖或实现超类型的方法< br />
@Override public void handleAbout(AppEvent.AboutEvent ae){
^

为什么我可以在IDE中运行它,但我不能告诉IDE将其编译为JAR?






尝试修复



我试图通过创建一个全新的NetBeans项目,复制所有源代码来完成重新创建项目的Ajith John的修复将文件放入其中,然后单击清理并生成。我得到了相同的结果,所以这不起作用。

解决方案

即使包 com.apple.eawt 在运行时jar rt.jar (如果在OS X上),编译器会查找包在名为 ct.sym 的符号文件中。符号文件仅包含标准Java包而不包含Apple扩展。



一种解决方案是使用javac选项 -XDignore.symbol.file ,如下所示。但是-XD选项是非标准且未记录的,请参阅



更好的解决方案可能是以不使用非标准Apple扩展的方式重写代码。


tl;dr

What dependency am I missing that allows NetBeans to run OS X-integrated program just fine internally, but not to be able to clean and build it to a JAR?


I'm trying to make a Java program that integrates into OS X, but I am hoping to release it onto Windows and Linux as well. To do this, I'm using the com.apple.eawt package's utility classes.

So far, it's been great. I've got my menu bar integrated into OS X, I've got Preferences Handlers and About Handlers and all that fun stuff and it's working great... when I'm just clicking Run in NetBeans. However! When I click Clean and Build, I get many, many errors like these:

/my/source/path/MenuBarManager.java:3: error: package com.apple.eawt does not exist
import com.apple.eawt.AboutHandler;
/my/source/path/MenuBarManager.java:62: error: cannot find symbol
    private static class MyAboutHandler implements AboutHandler {
                                                   ^
  symbol:   class AboutHandler
  location: class MyMenuBarManager
/my/source/path/MyMenuBarManager.java:68: error: package AppEvent does not exist
        @Override public void handleAbout(AppEvent.AboutEvent ae) {
                                          ^
/my/source/path/MyMenuBarManager.java:67: error: method does not override or implement a method from a supertype <br/>
        @Override public void handleAbout(AppEvent.AboutEvent ae) {
        ^

Why can I run it in the IDE just fine, but I can't tell the IDE to compile it to a JAR?


Attempted fix

I attempted Ajith John's fix of completely re-creating the project by making a brand new NetBeans project, copying all the source files into it, and clicking "Clean and Build". I got the same result, so this did not work.

解决方案

Even though the package com.apple.eawt is in the runtime jar rt.jar (if on OS X), the compiler looks for the package in a symbol file called ct.sym. The symbol file only contains the standard Java packages and not the Apple extensions.

One solution is to use the javac option -XDignore.symbol.file as shown below. However the -XD options are non-standard and undocumented, see here and here.

A better solution may be to rewrite the code in a way that doesn't use the non-standard Apple extensions.

这篇关于为什么NetBeans在OS X上运行我的程序,而不是将其构建到JAR中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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