Can't run JCEF Java project on Mac

Having problems with building or using the JCEF Java binding? Ask your questions here.

Can't run JCEF Java project on Mac

Postby freemanpolys » Sat Apr 29, 2017 10:50 am

Hi,

I'm failing to run JCEF project.
OS : MAC OX - El Capitain
Java : 1.7

I've just add the jar from jcef_build/native/Release/jcef.jar to the project.
Somebody help.

Error :

Code: Select all
Hello World!
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000010f590ad3, pid=23584, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (7.0_67-b01) (build 1.7.0_67-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [liblwawt.dylib+0xdad3]  JNI_OnLoad+0x91
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/sar/Documents/workspace-sts-3.7.2.RELEASE/TestJavaWebrtc/hs_err_pid23584.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
freemanpolys
Newbie
 
Posts: 4
Joined: Sat Apr 29, 2017 10:44 am

Re: Can't run JCEF Java project on Mac

Postby Czarek » Sat Apr 29, 2017 12:18 pm

What instructions have you followed? What example are you running? What CEF version?
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Can't run JCEF Java project on Mac

Postby freemanpolys » Sat May 06, 2017 11:14 am

Czarek wrote:What instructions have you followed? What example are you running? What CEF version?

I've followed this instructions : https://bitbucket.org/chromiumembedded/ ... ndBuilding
I've just clone https://bitbucket.org/chromiumembedded/java-cef.git like it's said in the docs.
For the testing purpose, I've create a Java project in Eclipse , create a project, add jcef_build/native/Release/jcef.jar as library, copy the code below from Internet and run it. ;)

Code: Select all
package test.sn;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import org.cef.CefApp;
import org.cef.CefClient;
import org.cef.OS;
import org.cef.browser.CefBrowser;

public class Principal {

   public static void main(String[] args) {
      // TODO Auto-generated method stub
        System.out.println("Hello World!");


//      JCefBrowser jCefBrowser = new JCefBrowser();
//      jCefBrowser.setSize(800, 600);
//      jCefBrowser.setVisible(true);



       /*
       * Gets the cef application singleton. It loads all resources
       * (native libraries etc.), initializes app...
       */
//      final CefApp cefApp = CefApp.getInstance();
       
        System.loadLibrary("jawt");


      final CefApp cefApp = CefApp.getInstance(new String[]{"-–disable-web-security","–enable-media-stream"});

       /*
       * You can create many browser instances per cef app (e.g.
       * used as browser tabs) Responsible for handling all
       * events from the browser instances.
       */
      final CefClient client = cefApp.createClient();

      /*
       * Browser instances are responsible for rendering of
       * the browser's content.
       */
      final CefBrowser browser = client.createBrowser(
          "http://www.google.com", OS.isMacintosh(), false);

      /*
       * Returns the browser's ui component used for
       * rendering in a awt application
       */
      final Component browserUI = browser.getUIComponent();

      // Create a new frame for holding the browser ui
      final JFrame mainFrame = new JFrame();

      // Add the browser ui to this newly created frame
      mainFrame.getContentPane().add(browserUI,
          BorderLayout.CENTER);

      // Show frame
      mainFrame.setSize(800, 600);
      mainFrame.setVisible(true);

      /*
       * Attach a handler to close the jcef application.
       * Dispose the JFrame and after that destroy the cefApp
       */
      mainFrame.addWindowListener(new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
              mainFrame.dispose();
              cefApp.dispose();
              // Alternative: CefApp.getInstance().dispose();
          }
      });
   }

}

freemanpolys
Newbie
 
Posts: 4
Joined: Sat Apr 29, 2017 10:44 am

Re: Can't run JCEF Java project on Mac

Postby waicool20 » Sun May 07, 2017 9:43 pm

freemanpolys wrote:
Czarek wrote:What instructions have you followed? What example are you running? What CEF version?

I've followed this instructions : https://bitbucket.org/chromiumembedded/ ... ndBuilding
I've just clone https://bitbucket.org/chromiumembedded/java-cef.git like it's said in the docs.
For the testing purpose, I've create a Java project in Eclipse , create a project, add jcef_build/native/Release/jcef.jar as library, copy the code below from Internet and run it. ;)

Code: Select all
package test.sn;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import org.cef.CefApp;
import org.cef.CefClient;
import org.cef.OS;
import org.cef.browser.CefBrowser;

public class Principal {

   public static void main(String[] args) {
      // TODO Auto-generated method stub
        System.out.println("Hello World!");


//      JCefBrowser jCefBrowser = new JCefBrowser();
//      jCefBrowser.setSize(800, 600);
//      jCefBrowser.setVisible(true);



       /*
       * Gets the cef application singleton. It loads all resources
       * (native libraries etc.), initializes app...
       */
//      final CefApp cefApp = CefApp.getInstance();
       
        System.loadLibrary("jawt");


      final CefApp cefApp = CefApp.getInstance(new String[]{"-–disable-web-security","–enable-media-stream"});

       /*
       * You can create many browser instances per cef app (e.g.
       * used as browser tabs) Responsible for handling all
       * events from the browser instances.
       */
      final CefClient client = cefApp.createClient();

      /*
       * Browser instances are responsible for rendering of
       * the browser's content.
       */
      final CefBrowser browser = client.createBrowser(
          "http://www.google.com", OS.isMacintosh(), false);

      /*
       * Returns the browser's ui component used for
       * rendering in a awt application
       */
      final Component browserUI = browser.getUIComponent();

      // Create a new frame for holding the browser ui
      final JFrame mainFrame = new JFrame();

      // Add the browser ui to this newly created frame
      mainFrame.getContentPane().add(browserUI,
          BorderLayout.CENTER);

      // Show frame
      mainFrame.setSize(800, 600);
      mainFrame.setVisible(true);

      /*
       * Attach a handler to close the jcef application.
       * Dispose the JFrame and after that destroy the cefApp
       */
      mainFrame.addWindowListener(new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
              mainFrame.dispose();
              cefApp.dispose();
              // Alternative: CefApp.getInstance().dispose();
          }
      });
   }

}



The other library files (jogl-all, jogl-all-natives, gluegen-all, gluegen-all-natives) also have to be on the classpath for JCEF to work. Just including jcef.jar wont work
waicool20
Newbie
 
Posts: 7
Joined: Sat Apr 22, 2017 3:40 am

Re: Can't run JCEF Java project on Mac

Postby freemanpolys » Mon May 08, 2017 3:30 pm

I've added all my build jar (screeshot below)
I'm still having issues :
Code: Select all
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000117ee8ad3, pid=78289, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (7.0_67-b01) (build 1.7.0_67-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [liblwawt.dylib+0xdad3]  JNI_OnLoad+0x91
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
Attachments
Capture d’écran 2017-05-08 à 20.25.36.png
Capture d’écran 2017-05-08 à 20.25.36.png (33.82 KiB) Viewed 11325 times
freemanpolys
Newbie
 
Posts: 4
Joined: Sat Apr 29, 2017 10:44 am

Re: Can't run JCEF Java project on Mac

Postby waicool20 » Mon May 08, 2017 9:08 pm

freemanpolys wrote:I've added all my build jar (screeshot below)
I'm still having issues :
Code: Select all
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000117ee8ad3, pid=78289, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (7.0_67-b01) (build 1.7.0_67-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [liblwawt.dylib+0xdad3]  JNI_OnLoad+0x91
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again


You also have to make sure that libcef.so and libjcef.so are on the java.library.path variable, since this error seems to indicate it can't load some of the native libraries, you can either patch the variable during runtime or you can add it during launch with the "-Djava.library.path=<Path>" switch.
waicool20
Newbie
 
Posts: 7
Joined: Sat Apr 22, 2017 3:40 am

Re: Can't run JCEF Java project on Mac

Postby freemanpolys » Sat May 13, 2017 6:53 am

I don't have libcef.so and libjcef.so in my build folder. I only have libjcef.dylib in my build folders. I have added libjcef.dylib as native library but It seems to look for liblwawt.dylib which I can't find.
Find below the folders contents screenshot.
Attachments
Capture d’écran 2017-05-13 à 11.49.34.png
build path libraries
Capture d’écran 2017-05-13 à 11.49.34.png (59.58 KiB) Viewed 11274 times
Capture d’écran 2017-05-13 à 11.45.37.png
jcef_build/native/Release/jcef_app.app/Contents/Java
Capture d’écran 2017-05-13 à 11.45.37.png (38.3 KiB) Viewed 11274 times
Capture d’écran 2017-05-13 à 11.43.07.png
jcef_build/native/Release
Capture d’écran 2017-05-13 à 11.43.07.png (28.18 KiB) Viewed 11274 times
freemanpolys
Newbie
 
Posts: 4
Joined: Sat Apr 29, 2017 10:44 am

Re: Can't run JCEF Java project on Mac

Postby waicool20 » Sun May 14, 2017 6:49 am

freemanpolys wrote:I don't have libcef.so and libjcef.so in my build folder. I only have libjcef.dylib in my build folders. I have added libjcef.dylib as native library but It seems to look for liblwawt.dylib which I can't find.
Find below the folders contents screenshot.


My bad those are for linux, mac should only have libjcef.dylib, if it can't find liblwawt.dylib try checking if it exists in <JRE ROOT>/lib/lwawt/liblwawt.dylib
waicool20
Newbie
 
Posts: 7
Joined: Sat Apr 22, 2017 3:40 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 17 guests