From a55b19b049e904198779ee9838af0ec2adac1122 Mon Sep 17 00:00:00 2001 From: 1zuna Date: Tue, 12 Mar 2024 02:12:39 +0100 Subject: [PATCH] pass jcef lib path directly --- java/org/cef/CefApp.java | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/java/org/cef/CefApp.java b/java/org/cef/CefApp.java index eff69e01..45f39ec8 100644 --- a/java/org/cef/CefApp.java +++ b/java/org/cef/CefApp.java @@ -8,17 +8,12 @@ import org.cef.handler.CefAppHandler; import org.cef.handler.CefAppHandlerAdapter; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import javax.swing.*; import java.io.File; -import java.io.FilenameFilter; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashSet; -import javax.swing.SwingUtilities; -import javax.swing.Timer; - /** * Exposes static methods for managing the global CEF context. */ @@ -434,23 +429,30 @@ public final void doMessageLoopWork(final long delay_ms) { * @param args Command-line arguments massed to main(). * @return True on successful startup. */ - public static final boolean startup(String[] args) { - String jcefPath = getJcefLibPath(); + public static final boolean startup(Path librariesPath, String[] args) { + Path jcefPath; + if (OS.isMacintosh()) { + jcefPath = librariesPath.resolve("jcef_app.app/Contents/Java"); + } else { + jcefPath = librariesPath; + } + + String jcefPathStr = jcefPath.toAbsolutePath().toString(); if (OS.isWindows()) { - System.load(jcefPath + "/d3dcompiler_47.dll"); - System.load(jcefPath + "/libGLESv2.dll"); - System.load(jcefPath + "/libEGL.dll"); - System.load(jcefPath + "/chrome_elf.dll"); - System.load(jcefPath + "/libcef.dll"); - System.load(jcefPath + "/jcef.dll"); + System.load(jcefPathStr + "/d3dcompiler_47.dll"); + System.load(jcefPathStr + "/libGLESv2.dll"); + System.load(jcefPathStr + "/libEGL.dll"); + System.load(jcefPathStr + "/chrome_elf.dll"); + System.load(jcefPathStr + "/libcef.dll"); + System.load(jcefPathStr + "/jcef.dll"); return true; } else if (OS.isMacintosh()) { - System.load(jcefPath + "/libjcef.dylib"); + System.load(jcefPathStr + "/libjcef.dylib"); return N_Startup(getCefFrameworkPath(args)); } else if (OS.isLinux()) { - System.load(jcefPath + "/libcef.so"); - System.load(jcefPath + "/libjcef.so"); + System.load(jcefPathStr + "/libcef.so"); + System.load(jcefPathStr + "/libjcef.so"); return N_Startup(null); } @@ -461,7 +463,7 @@ public static final boolean startup(String[] args) { * Get the path which contains the jcef library * @return The path to the jcef library */ - private static final String getJcefLibPath() { + private static String getJcefLibPath() { Path librariesPath = Paths.get(System.getProperty("jcef.path")); Path jcefPath;