如何启用/允许java在CefSharp应用程序中运行

时间:2014-10-11 15:37:19

标签: c# wpf chromium-embedded cefsharp

我们正在制作一个Web浏览器来试验Oracle的ADT / Forms技术。它需要做的就是转到Web地址并运行Java applet。

我正在使用(至少尝试)CefSharp3(来自https://github.com/cefsharp/CefSharp的新克隆)。

我为此创建了一个WPF项目,让它工作(我可以导航到Google,这里,Oracle等)但是,当我导航到我们的Java applet时,我似乎只得到一个空白屏幕。

我已设置浏览器属性

  • “JavaDisabled”
  • “PluginsDisabled”
  • “WebSecurityDisabled”

(抓住那里的稻草!),我只看到一个空白的屏幕。

我想知道该应用程序是否没有JRE的权限?也许JRE需要包含在项目中?

这是Debug文件的结果(在仅运行Java applet的新运行之后)

[1011/121439:WARNING:resource_bundle.cc(280)] locale_file_path.empty()
[1011/121439:WARNING:resource_bundle.cc(280)] locale_file_path.empty()
[1011/121439:WARNING:resource_bundle.cc(280)] locale_file_path.empty()
[1011/121439:ERROR:renderer_main.cc(226)] Running without renderer sandbox
[1011/121441:WARNING:content_browser_client.cc(480)] No browser info matching view process id 3 and routing id 2
[1011/121441:WARNING:content_browser_client.cc(480)] No browser info matching view process id 3 and routing id 2
[1011/121441:WARNING:content_browser_client.cc(480)] No browser info matching view process id 3 and routing id 2
[1011/121441:WARNING:resource_bundle.cc(280)] locale_file_path.empty()
[1011/121441:WARNING:content_browser_client.cc(480)] No browser info matching view process id 3 and routing id 2
[1011/121441:WARNING:content_browser_client.cc(480)] No browser info matching view process id 3 and routing id 2
[1011/121441:WARNING:content_browser_client.cc(480)] No browser info matching view process id 3 and routing id 2

Java applet在Firefox,Chrome,IE和Chromium(使用WinForms)中没有问题。可能只是WPF和Java没有jive。

这是一些代码! - 它并不多,但使用这个框架并不需要太多 - 我印象非常深刻。

public partial class MainWindow : Window
{
    public MainWindow() {

        InitializeCef();
        InitializeComponent();
        SetBrowserSettings();

        ((IWebBrowser)webBrowser).Load("URL_To_Java_Applet");
    }

    private void InitializeCef() {
        var settings = new CefSharp.CefSettings()
        {
            PackLoadingDisabled = true
        };
        settings.IgnoreCertificateErrors = true; // could be preventing the JRE?
        Cef.Initialize(settings);
    }

    private void SetBrowserSettings() {
        BrowserSettings settings = new BrowserSettings();
        settings.JavaDisabled = false;
        settings.PluginsDisabled = false;
        settings.WebSecurityDisabled = true; // desperate attempt to allow JRE to run!
        webBrowser.BrowserSettings = settings;
    }
}

1 个答案:

答案 0 :(得分:0)

看起来你是对的......

  

可能只是WPF和Java没有jive。

尝试使用WinForms,而不是前景看起来不好的WPF(注意WPF在OSR模式下运行)

请参阅此CEF forum thread

更新:我尝试使用http://java.com/en/download/installed8.jsp和Win32版本的CefSharp.Winforms | Wpf.Example - 它们都按预期使用JRE 7.67 x86。当然x64示例不起作用,因为我的PC上没有x64 JRE。