How can I run a libGDX application on a non-GUI server environment?(如何在非 GUI 服务器环境中运行 libGDX 应用程序?)
问题描述
我构建了一个在我的 PC 桌面上运行良好的 libGDX 应用程序,但是当我尝试在我的 Ubuntu 服务器上运行它时,它会引发以下错误:
I built a libGDX application that runs well on my PC desktop but when I try to run it on my Ubuntu server, it raises the following error:
"LwjglApplication: 无法初始化音频,禁用音频java.lang.UnsatisfiedLinkError:/tmp/libgdxroot/31ce78a2/liblwjgl64.so:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/../lib/amd64/libjawt.so:符号awt_Unlock,版本 SUNWprivate_1.1 未在文件 libmawt.so 中定义链接时间参考".
"LwjglApplication: Couldn't initialize audio, disabling audio java.lang.UnsatisfiedLinkError: /tmp/libgdxroot/31ce78a2/liblwjgl64.so: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/../lib/amd64/libjawt.so: symbol awt_Unlock, version SUNWprivate_1.1 not defined in file libmawt.so with link time reference".
我知道这是因为我的服务器在非 GUI 模式下运行.但是我怎样才能在这个环境中运行我的 libGDX 应用程序呢?我听说过libGDX 无头后端".但我不知道如何使用它.提前致谢.
I know this is because my server is running in non-GUI mode. But how can I run my libGDX app in this environment?. I've heard about "libGDX headless backend". But I don't know how to use it. Thanks in advance.
推荐答案
我已经为任何正在寻找这个问题的人回答了这个问题.首先,在 build.gradle 文件中添加这两个库:
I've answer my self this question for anyone who's looking for this. First, added these two libraries in the build.gradle file:
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
compile "org.mockito:mockito-all:1.9.5"
然后,我启动了我的 libGDX,如下所示:
Then, I've started my libGDX as following:
HeadlessNativesLoader.load();
MockGraphics mockGraphics = new MockGraphics();
Gdx.graphics = mockGraphics;
HeadlessNet headlessNet = new HeadlessNet();
Gdx.net = headlessNet;
HeadlessFiles headlessFiles = new HeadlessFiles();
Gdx.files = headlessFiles;
Gdx.gl = mock(GL20.class);
HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration();
ApplicationListener myGdxGame = EntryPoint.getHeadlessMyGdxGame(config);
和 EntryPoint.getHeadlessMyGdxGame 返回 HeadlessApplication 的继承
and EntryPoint.getHeadlessMyGdxGame return an inherited of HeadlessApplication
这篇关于如何在非 GUI 服务器环境中运行 libGDX 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在非 GUI 服务器环境中运行 libGDX 应用程序
基础教程推荐
- 如何对 HashSet 进行排序? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01