Is it nessary to add JRE path in enviroment veriable

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

Is it nessary to add JRE path in enviroment veriable

Postby rover886 » Wed Dec 17, 2014 3:45 am

I have created an sample application embedded with JCEF all the dependencies (.jar) files are added. When I try to run jar file from command prompt using command

java -Djava.library.path=E:\Downloads\jcef_binary_3.1750.1738.91_windows64\jcef_binary_3.1750.1738.91\bin\lib\win64\ -jar mavenproject1-1.0-SNAPSHOT-jar-with-dependencies.jar


I got error as :

Code: Select all
Exception in thread "main" java.lang.UnsatisfiedLinkError: E:\Downloads\jcef_bin
ary_3.1750.1738.91_windows64\jcef_binary_3.1750.1738.91\bin\lib\win64\jcef.dll:
Can't find dependent libraries
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary1(Unknown Source)
        at java.lang.ClassLoader.loadLibrary0(Unknown Source)
        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:54)
        at org.cef.CefApp.getInstance(CefApp.java:75)
        at org.cef.CefApp.getInstance(CefApp.java:70)
        at test.mavenproject1.Main.<init>(Main.java:50)
        at test.mavenproject1.Main.main(Main.java:126)


If I tun program using command: (provided full path of java.exe)

"c:\Program Files\Java\jre7\bin\java.exe" -Djava.library.path=E:\Downloads\jcef_binary_3.1750.1738.91_windows64\jcef_binary_3.1750.1738.91\bin\lib\win64\ -jar mavenproject1-1.0-SNAPSHOT-jar-with-dependencies.jar


I come to know that jcef.dll require some dll from /jre7/bin/ like jawt.dll,awt.dll etc.

so is it necessary to set jre path into environment variable?
rover886
Techie
 
Posts: 19
Joined: Fri Mar 14, 2014 4:34 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby kaiklimke » Wed Dec 17, 2014 4:14 am

Normally you don't need to set the environment variable. Try to run the initialization of CefApp within the EDT Thread:

Code: Select all
if (SwingUtilities.isEventDispatchThread()) {
  CefApp.getInstance();
  ....
} else {
  SwingUtilities.invokeAndWait(new Runnable() {
    @Override
    public void run() {
      CefApp.getInstance();
      ....
    });
}


In the EDT all required Java libraries (e.g. jawt.dll or awt.dll) are already loaded.

Regards,
Kai
kaiklimke
Techie
 
Posts: 19
Joined: Tue Oct 29, 2013 3:49 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby rover886 » Wed Dec 17, 2014 6:03 am

I have tried as you said still I am getting error I remove jre path from environment variable:

Error:

D:\__MKCLDevelopment\temp\mavenproject1\target>java -Djava.library.path=D:\__MKC
LDevelopment\temp\lib\ -jar mavenproject1-1.0-SNAPSHOT-jar-with-dependencies.jar

Dec 17, 2014 4:25:34 PM test.mavenproject1.Main main
SEVERE: null
java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
at test.mavenproject1.Main.<init>(Main.java:61)
at test.mavenproject1.Main.main(Main.java:143)
Caused by: java.lang.UnsatisfiedLinkError: D:\__MKCLDevelopment\temp\lib\jcef.dl
l: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
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:54)
at org.cef.CefApp.getInstance(CefApp.java:75)
at org.cef.CefApp.getInstance(CefApp.java:70)
at test.mavenproject1.Main$1.run(Main.java:64)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Code:

Code: Select all
     final AtomicReference<CefApp> obj_= new AtomicReference<CefApp>();
      if (SwingUtilities.isEventDispatchThread()) {
            cefApp_ = CefApp.getInstance();
      }
      else
      {
          SwingUtilities.invokeAndWait(new Runnable() {             
            @Override
            public void run() {     
                 obj_.set(CefApp.getInstance()); // according to stackTrace error occurred here; Line no. 64
            }});     
          cefApp_=obj_.get();
      }

    client_ = cefApp_.createClient();
rover886
Techie
 
Posts: 19
Joined: Fri Mar 14, 2014 4:34 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby kaiklimke » Wed Dec 17, 2014 6:27 am

You're using JCEF Rev. 91. I think you're addressing this issue:
https://code.google.com/p/javachromiumembedded/issues/detail?id=118&can=1&start=100
which is fixed in newer versions.

I would recommend you to check out the latest JCEF version from SVN and to build it as described here:
https://code.google.com/p/javachromiume ... ndBuilding

Regards, Kai
kaiklimke
Techie
 
Posts: 19
Joined: Tue Oct 29, 2013 3:49 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby kaiklimke » Wed Dec 17, 2014 6:29 am

... or as workaround try to add
Code: Select all
System.loadLibrary("jawt");

just before executing CefApp.getInstance();
kaiklimke
Techie
 
Posts: 19
Joined: Tue Oct 29, 2013 3:49 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby rover886 » Wed Dec 17, 2014 7:30 am

kaiklimke wrote:You're using JCEF Rev. 91. I think you're addressing this issue:


I have downloaded JCEF from This URL

Do I still need to take update of JCEF (Is it necessary?)

adding
kaiklimke wrote:System.loadLibrary("jawt");
Worked in my case.

Which solution is best according to you. whether to use EDT Thread or System.loadLibrary()
rover886
Techie
 
Posts: 19
Joined: Fri Mar 14, 2014 4:34 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby kaiklimke » Wed Dec 17, 2014 8:25 am

I have downloaded JCEF from This URL

The binary distribution doesn't contain the latest svn build. See also http://www.magpcss.org/ceforum/viewtopic.php?f=17&t=12187.

The svn trunk contains all fixes since the last binary distribution, so I personally prefer to use the latest self-build-trunk version.
But if you doesn't get any trouble, you're fine with the binary distribution.
One hint: If you run in an issue, you can have a look onto https://code.google.com/p/javachromiumembedded/issues/list?can=1&q=&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles and check if it is already fixed.

Which solution is best according to you. whether to use EDT Thread or System.loadLibrary()

If System.loadLibrary() works fine for you without the EDT Thread, I would go that way. But it doesn't hurt if you combine both suggestions (esp. if you plan to use Mac OS X or Linux beside Windows).

Regards,
Kai
kaiklimke
Techie
 
Posts: 19
Joined: Tue Oct 29, 2013 3:49 am

Re: Is it nessary to add JRE path in enviroment veriable

Postby rover886 » Wed Dec 17, 2014 8:38 am

Thanks, Thank you so much for your valuable answer.

I will be glad if you help in issue viewtopic.php?f=17&t=12519 :)
rover886
Techie
 
Posts: 19
Joined: Fri Mar 14, 2014 4:34 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 36 guests