且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

摇篮SwingBuilder:QUOT&;工具包未发现:apple.awt.CToolkit"错误

更新时间:2022-10-15 11:20:09

根据 GitHub上这个问题,这个问题似乎是与IntelliJ IDEA的默认Java 6的运行的事实。你需要迫使它与Java 7上运行,而不是,如这个JetBrains的支持文章。

有一件事要记住的是,拥有的IntelliJ与Java 7及以上的Mac问题,这就是为什么它默认为Java 6.您可以在支持文章我联系了解详情。

I have a Gradle task that is supposed to prompt if the user wants to continue or not (part of a larger task for my Android app).

I'm using SwingBuilder to to try construct a dialog but I'm getting the following error when I try to build:

Error:(94) Execution failed for task ':XXXXXX:ask'.
> Toolkit not found: apple.awt.CToolkit    

Obviously, I don't have something installed on my Mac but I'm not sure what I need to install. Is this a Java dependency? Or Gradle? (Googling this does not help very much either - the only relevant link is something to do with Google AppEngine which does not help me much).

Here's the task:

task ask << {
    def pass = ''
    new SwingBuilder().edt {
        dialog(modal: true, 
                title: 'Continue',
                alwaysOnTop: true, 
                resizable: false, 
                locationRelativeTo: null, 
                pack: true, 
                show: true 
        ) {
            vbox { 
                label(text: "Are you sure you want to continue?")
                button(defaultButton: true, text: 'Continue', actionPerformed: {
                    //do something
                    dispose(); 
                })

                button(defaultButton: true, text: 'Cancel', actionPerformed: {
                    //do something
                    dispose(); // Close dialog
                })
            }
        }
    }

According to this issue on GitHub, the problem appears to be with the fact that IntelliJ IDEA runs on Java 6 by default. You'll need to force it to run with Java 7 instead, as described in this JetBrains support article.

One thing to bear in mind is that IntelliJ has problems with Java 7 and above on Mac, which is why it defaults to Java 6. You can find more details in that support article I linked to.