Caused by: java.lang.RuntimeException: JxBrowser license check failed: No valid license found

时间:2022-08-17 10:50:49

使用jxbrower报错,原因时证书检验失败,

解决方案:

1.首先创建证书,下面是我在IDEA maven项目中创建的位置,Java项目中在src/目录下创建,

META-INF/teamdev.licenses

Product: JxBrowser
Version: 6.x
Licensed to:POPK
License type: Enterprise
License info: JxBrowser License
Expiration date: 01-01-9999
Support expiration date: NO SUPPORT
Generation date: 01-01-1970
Platforms: win32/x86;win32/x64;mac/x86;mac/x64;linux/x86;linux/x64
Company name: TeamDev Ltd.
SigB: 1
SigA: 1

Caused by: java.lang.RuntimeException: JxBrowser license check failed: No valid license found

2.添加静态代码

static {
try {
Field e = aq.class.getDeclaredField("e");
e.setAccessible(true);
Field f = aq.class.getDeclaredField("f");
f.setAccessible(true);
Field modifersField = Field.class.getDeclaredField("modifiers");
modifersField.setAccessible(true);
modifersField.setInt(e, e.getModifiers() & ~Modifier.FINAL);
modifersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
e.set(null, new BigInteger("1"));
f.set(null, new BigInteger("1"));
modifersField.setAccessible(false);
} catch (Exception e1) {
e1.printStackTrace();
}
}
可以将静态代码段添加在项目启动处
此代码针对jxbrowser-win-6.6.jar版本,原理就是通过反射来修改字段,使验证通过,(不同版本需反射的类不同,)。

Caused by: java.lang.RuntimeException: JxBrowser license check failed: No valid license found