【发布时间】:2018-10-04 13:10:26
【问题描述】:
我在我的 Java 8 应用程序中使用了 Processing,它在 IntelliJ 上运行良好。 Gradle导出所有平台的fat jar(代码如下)打包依赖后出现问题:
jar {
baseName = applicationName
version = actualVersion
manifest { attributes 'Main-Class': mainClassName }
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
每当我尝试打开扩展 PApplet 的窗口时,都会引发此异常:
com.jogamp.opengl.GLException: Profiles [GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2] 在设备上不可用 WindowsGraphicsDevice[type .windows, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock [obj 0x76dc78af]] 在 com.jogamp.opengl.GLProfile.get(GLProfile.java:1039) 在 com.jogamp.opengl.GLProfile.get(GLProfile.java:1050) 在 com.jogamp.opengl.GLProfile.getMaxProgrammable(GLProfile.java:826) 在 processing.opengl.PSurfaceJOGL.initGL(PSurfaceJOGL.java:203) 在 processing.opengl.PSurfaceJOGL.initFrame(PSurfaceJOGL.java:136) 在 processing.core.PApplet.initSurface(PApplet.java:10877) 在 processing.core.PApplet.runSketch(PApplet.java:10764) 在 processing.core.PApplet.main(PApplet.java:10501) 在 processing.core.PApplet.main(PApplet.java:10483)
这是我的依赖项
dependencies {
compile 'org.processing:core:3.3.5'
compile 'org.jogamp.jogl:jogl-all:2.3.2'
compile 'org.jogamp.gluegen:gluegen-rt:2.3.2'
testCompile 'org.json:json:20180130'
compile files('libs/proscene.jar', 'libs/controlP5.jar')
runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-macosx-universal"
runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-windows-amd64"
runtime "org.jogamp.gluegen:gluegen-rt:2.3.2:natives-windows-i586"
runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-macosx-universal"
// runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-solaris-i586"
runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-windows-amd64"
runtime "org.jogamp.jogl:jogl-all:2.3.2:natives-windows-i586"
testCompile('org.junit.jupiter:junit-jupiter-api:5.1.0',
'org.junit.jupiter:junit-jupiter-params:5.1.0')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.1.0',
'org.junit.platform:junit-platform-launcher:1.1.0')
}
挖掘处理和 JOGL 论坛并没有多大帮助。我该怎么办?
P/S:一件奇怪的事情是通过 Eclipse 导出 fat jar 会以某种方式使 jar 中的 jogl 可运行。
【问题讨论】:
-
这可能与 JOGL 如何处理其原生依赖关系有关。如果我是你,我会先比较两个 jar 文件的内容。 Eclipse 版本是否包含 Intellij 版本不包含的任何文件?
-
我已经比较了这两个。相当混乱,因为 Eclipse 还打包了测试类。但似乎 Eclipse 包包含 *jogamp\nativetag\opengl*,它没有出现在 Gradle 导出包中。
-
是的,听起来您想将它们包含在您的 Intellij jar 中。我不确定该怎么做,但至少你有一个地方可以开始你的谷歌搜索。
标签: java opengl gradle jar processing