不能使用从代号一创建 CEF 浏览器

时间:2021-05-03 17:19:58

标签: java linux codenameone archlinux

每次我尝试在代号为 1 中调用它时,我的应用程序都无法运行 BrowserComponent。它给我一个创建 CEF 浏览器失败的错误。旁边的一切都运行得很好。我按照此链接中的说明卸载并安装了 CEF Codename One CEF Support 我试图解决我的问题,因为我在上一个链接的已知问题中找到了它

我按照指示进行操作并尝试修复LD_LIBRARY_PATH

这是我这样做后终端的输出:

[kagha@archbios ~]$ whereis java
java: /usr/bin/java /usr/share/java /usr/lib/jvm/java-8-jdk/bin/java
[kagha@archbios ~]$ echo $JAVA_HOME
/usr/lib/jvm/java-8-jdk
[kagha@archbios ~]$ echo  $LD_LIBRARY_PATH
/usr/lib/jvm/java-8-jdk/lib/amd64
[kagha@archbios ~]$ find /usr/lib/jvm/java-8-jdk/ | grep "libawt.so"
/usr/lib/jvm/java-8-jdk/jre/lib/amd64/libawt.so

但问题仍然存在 我使用 OS Arch Linux 内核版本 5.10.32-1-lts 和 Apache netbeans 12.1 作为 IDE

我试图运行的代码

Form hi = new Form("Browser", new BorderLayout());
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://www.codenameone.com/");
hi.add(BorderLayout.CENTER, browser);*/

这是控制台中的完整错误:

[EDT] 0:0:0,282 - Attempting to create browser component
[AWT-EventQueue-0] 0:0:0,284 - Attempting to create browser component
java.lang.UnsatisfiedLinkError: /home/kagha/.codenameone/cef/lib/linux64/libjcef.so: libjawt.so: cannot open shared object file: No such file or directory
[EDT] 0:0:0,326 - Exception: java.lang.UnsatisfiedLinkError - /home/kagha/.codenameone/cef/lib/linux64/libjcef.so: libjawt.so: cannot open shared object file: No such file or directory
[EDT] 0:0:0,327 - Exception: java.lang.RuntimeException - Failed to create CEF browser
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1830)
    at java.lang.Runtime.loadLibrary0(Runtime.java:871)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.cef.SystemBootstrap$1.loadLibrary(SystemBootstrap.java:24)
    at org.cef.SystemBootstrap.loadLibrary(SystemBootstrap.java:36)
    at org.cef.CefApp.startup(CefApp.java:536)
    at com.codename1.impl.javase.cef.CEFBrowserComponent.create(CEFBrowserComponent.java:207)
    at com.codename1.impl.javase.cef.CEFBrowserComponent.create(CEFBrowserComponent.java:199)
    at com.codename1.impl.javase.cef.CEFBrowserComponent.create(CEFBrowserComponent.java:196)
    at com.codename1.impl.javase.cef.JavaCEFSEPort.createCEFBrowserComponent(JavaCEFSEPort.java:139)
    at com.codename1.impl.javase.cef.JavaCEFSEPort$2.run(JavaCEFSEPort.java:121)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
java.lang.RuntimeException: Failed to create CEF browser
    at com.codename1.impl.javase.cef.JavaCEFSEPort.createCEFBrowserComponent(JavaCEFSEPort.java:133)
    at com.codename1.impl.javase.cef.JavaCEFSEPort.createBrowserComponent(JavaCEFSEPort.java:98)
    at com.codename1.ui.BrowserComponent$9.run(BrowserComponent.java:557)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1338)
    at com.codename1.ui.Display.edtLoopImpl(Display.java:1280)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:1162)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Caused by: java.lang.UnsatisfiedLinkError: /home/kagha/.codenameone/cef/lib/linux64/libjcef.so: libjawt.so: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1830)
    at java.lang.Runtime.loadLibrary0(Runtime.java:871)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.cef.SystemBootstrap$1.loadLibrary(SystemBootstrap.java:24)
    at org.cef.SystemBootstrap.loadLibrary(SystemBootstrap.java:36)
    at org.cef.CefApp.startup(CefApp.java:536)
    at com.codename1.impl.javase.cef.CEFBrowserComponent.create(CEFBrowserComponent.java:207)
    at com.codename1.impl.javase.cef.CEFBrowserComponent.create(CEFBrowserComponent.java:199)
    at com.codename1.impl.javase.cef.CEFBrowserComponent.create(CEFBrowserComponent.java:196)
    at com.codename1.impl.javase.cef.JavaCEFSEPort.createCEFBrowserComponent(JavaCEFSEPort.java:139)
    at com.codename1.impl.javase.cef.JavaCEFSEPort$2.run(JavaCEFSEPort.java:121)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
BUILD SUCCESSFUL (total time: 8 seconds)

如果需要,我将不胜感激并提供更多信息,提前致谢

1 个答案:

答案 0 :(得分:0)

您应该使用新的 Maven support。这应该可以解决问题,因为 Maven 插件会自动将所需的条目添加到 LD_LIBRARY_PATH

您可以从 https://start.codenameone.com 下载基本模板并将您的代码粘贴到那里。