簡體   English   中英

使用Java在Eclipse中進行CEF開發

[英]CEF development in Eclipse with Java

我正在嘗試為Java應用程序開發瀏覽器,我找到了JCEF 我做了這個指南沒有任何錯誤。 現在我想嘗試一下簡單的例子“MainFrame.Java”,它也是構建的。 我在eclipse中創建了一個項目,將jar文件添加到庫中並復制了MainFrame文件。

如果我運行它,我會收到此錯誤:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jcef in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.cef.CefApp.<init>(CefApp.java:157)
at org.cef.CefApp.getInstance(CefApp.java:246)
at org.cef.CefApp.getInstance(CefApp.java:233)
at test.MainFrame.<init>(MainFrame.java:71)
at test.MainFrame.main(MainFrame.java:154)

我還嘗試了本課題中描述的步驟和評論中的鏈接。 但是如果我在第一步中下載文件,我就沒有所描述的文件或路徑。

有人知道如何讓它運行或我完全錯了嗎?

MainFrame文件的代碼:

public class MainFrame extends JFrame {
private static final long serialVersionUID = -5570653778104813836L;
private final JTextField address_;
private final CefApp cefApp_;
private final CefClient client_;
private final CefBrowser browser_;
private final Component browerUI_;

/**
 * To display a simple browser window, it suffices completely to create an
 * instance of the class CefBrowser and to assign its UI component to your
 * application (e.g. to your content pane). But to be more verbose, this
 * CTOR keeps an instance of each object on the way to the browser UI.
 */
private MainFrame(String startURL, boolean useOSR, boolean isTransparent) {

    CefApp.addAppHandler(new CefAppHandlerAdapter(null) {
        @Override
        public void stateHasChanged(org.cef.CefApp.CefAppState state) {
            // Shutdown the app if the native CEF part is terminated
            if (state == CefAppState.TERMINATED)
                System.exit(0);
        }
    });
    CefSettings settings = new CefSettings();
    settings.windowless_rendering_enabled = useOSR;
    cefApp_ = CefApp.getInstance(settings);

    client_ = cefApp_.createClient();

    browser_ = client_.createBrowser(startURL, useOSR, isTransparent);
    browerUI_ = browser_.getUIComponent();

    address_ = new JTextField(startURL, 100);
    address_.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            browser_.loadURL(address_.getText());
        }
    });

    getContentPane().add(address_, BorderLayout.NORTH);
    getContentPane().add(browerUI_, BorderLayout.CENTER);
    pack();
    setSize(800, 600);
    setVisible(true);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            CefApp.getInstance().dispose();
            dispose();
        }
    });
}

public static void main(String[] args) {
    new MainFrame("http://www.google.com", OS.isLinux(), false);
}

}

我搞定了。 我的問題是我沒有正確地構建二進制文件

暫無
暫無

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

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