Could not initialize class 问题解决

时间:2025-02-28 21:15:23

最近提供需要提供音视频服务。参考网上的开源程序,提供了一个JAVA版的RTSP转HTTP的服务,并使用ffmpeg作为播放工具。

该程序在自己的机器上没有问题,但生成jar包后放置到服务器上运行出错,出错的关键字是“:Could not initialize class ”。

服务器是Windows Server2008。

最开始想的是Windows Server2008不支持流媒体服务造成的,安装上KB963697,然后通过MCC安装上流媒体服务后,发现依然如此。

找解决方案,找到了这几篇博客:【FAQ】解决报错Could not initialize class .avutil_bytedeco 报错_weixin_42534940的博客-****博客

解决:Could not initialize class .avutil_Cyz971010的博客-****博客

/questions/42829974/java-lang-noclassdeffounderror-could-not-initialize-class-org-bytedeco-javacpp

CameraServerApplication启动失败 · Issue #I2DAD9 · banmajio/RTSPtoHTTP-FLV -

javacv使用笔记 - 雾非雾的情思

发现这一系列提供的解决方案均无法解决该问题,但给了一个思路,是java库的版本的问题。

最后发现github上的javacvGitHub - bytedeco/javacv: Java interface to OpenCV, FFmpeg, and mores​​​​​​​s​​​​​​​s

上面有最新的库配置,文件如下:

<dependencies>
	<dependency>
		<groupId></groupId>
		<artifactId>javacv-platform</artifactId>
		<version>1.5.9</version>
	</dependency>

	<!-- Additional dependencies required to use CUDA and cuDNN -->
	<dependency>
		<groupId></groupId>
		<artifactId>opencv-platform-gpu</artifactId>
		<version>4.7.0-1.5.9</version>
	</dependency>

	<!-- Optional GPL builds with (almost) everything enabled -->
	<dependency>
		<groupId></groupId>
		<artifactId>ffmpeg-platform-gpl</artifactId>
		<version>6.0-1.5.9</version>
	</dependency>
</dependencies>

修改该文件的,和上面一致,问题解决。