簡體   English   中英

帶有 GUI 的 Java 將無法運行

[英]Java with GUIs won't run

嗨,我需要有關 Mac 上 Java 的幫助。 我已經徹底卸載了所有版本的 Java 並安裝了 Oracle JDK 1.8.0_202。 我可以執行 javac 和 java - 並編譯和運行在控制台中運行的簡單程序。 但是 - 當我嘗試使用窗戶進行任何操作時 - 它會掛起。

這包括所有 gui 應用程序、java web 啟動,甚至 Java 控制面板都不會啟動 - 它只是停止響應並且不顯示任何內容。

這個簡單的應用程序也有相同的行為:

import javax.swing.*;        

public class HelloWorldSwing {
/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("HelloWorldSwing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add the ubiquitous "Hello World" label.
    JLabel label = new JLabel("Hello World");
    frame.getContentPane().add(label);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

}

我嘗試過重新安裝、重新啟動等任何操作,但仍然無法運行這個簡單的程序。 我在運行它的終端中沒有收到任何錯誤消息 - 它只是凍結了。

請幫助我解決此問題並獲得有效的 Java 設置。

我正在使用帶有 Mojave 10.14.3 的 Macbook pro

編輯

實際上真正的罪魁禍首是顯示鏈接。 如果您在使用 Java 和 GUI 時遇到問題 - 可能是因為您使用的是 Display Link 並且驅動程序與 Java 沖突。 僅當您的筆記本電腦屏幕關閉時。

有關更多信息,請參閱https://displaylink.org/forum/showthread.php?t=66556

我希望這可以幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM