This post was updated on .
I want to start learning OpenGL with JOGL, tried but cannot run any example so far.
To not repeat myself in whole details, I created a post a Stack Overflow already: https://stackoverflow.com/questions/69058541/jogl-2-3-2-example-compiles-but-fails-to-run-maven-in-netbeans-12-4 According to an answer there I switch for future questions to this official forum. I followed the answer given at Stack Overflow, created a new Java with Maven project in NetBeans 12.4, and created the mentioned example RawGL2ES2demo.java, also added just the two dependencies to the pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany</groupId> <artifactId>JOGLsecond</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>16</maven.compiler.source> <maven.compiler.target>16</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.jogamp.gluegen</groupId> <artifactId>gluegen-rt-main</artifactId> <version>2.3.2</version> </dependency> <dependency> <groupId>org.jogamp.jogl</groupId> <artifactId>jogl-all-main</artifactId> <version>2.3.2</version> </dependency> </dependencies> </project> The project compiles (Clean and Build), but when I do Run File on the RawGL2ES2demo.java I get the following error: cd /home/me/NetBeansProjects/JOGLsecond; JAVA_HOME=/home/me/PROGRAMs/openjdk-16.0.2 M2_HOME=/home/me/PROGRAMs/apache-maven-3.8.2 /home/me/PROGRAMs/apache-maven-3.8.2/bin/mvn -Dexec.vmArgs= "-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}" -Dexec.executable=/home/me/PROGRAMs/openjdk-16.0.2/bin/java -Dexec.mainClass=com.mycompany.joglsecond.RawGL2ES2demo -Dexec.classpathScope=runtime -DskipTests=true -Dexec.appArgs= org.codehaus.mojo:exec-maven-plugin:3.0.0:exec Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts. Scanning for projects... ----------------------< com.mycompany:JOGLsecond >---------------------- Building JOGLsecond 1.0-SNAPSHOT --------------------------------[ jar ]--------------------------------- --- exec-maven-plugin:3.0.0:exec (default-cli) @ JOGLsecond --- Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln6197218351352021716/jln3368270845480343845/natives/linux-amd64/libnativewindow_awt.so: /home/me/PROGRAMs/openjdk-16.0.2/lib/libjawt.so: version `SUNWprivate_1.1' not found (required by /tmp/jogamp_0000/file_cache/jln6197218351352021716/jln3368270845480343845/natives/linux-amd64/libnativewindow_awt.so) at java.base/jdk.internal.loader.NativeLibraries.load(Native Method) at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383) at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227) at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169) at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383) at java.base/java.lang.Runtime.load0(Runtime.java:746) at java.base/java.lang.System.load(System.java:1857) at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:603) at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:63) at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:106) at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:487) at jogamp.nativewindow.NWJNILibLoader.access$000(NWJNILibLoader.java:39) at jogamp.nativewindow.NWJNILibLoader$1.run(NWJNILibLoader.java:49) at jogamp.nativewindow.NWJNILibLoader$1.run(NWJNILibLoader.java:41) at java.base/java.security.AccessController.doPrivileged(AccessController.java:312) at jogamp.nativewindow.NWJNILibLoader.loadNativeWindow(NWJNILibLoader.java:41) at jogamp.nativewindow.jawt.JAWTUtil.<clinit>(JAWTUtil.java:336) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:466) at com.jogamp.nativewindow.NativeWindowFactory$3.run(NativeWindowFactory.java:344) at com.jogamp.nativewindow.NativeWindowFactory$3.run(NativeWindowFactory.java:340) at java.base/java.security.AccessController.doPrivileged(AccessController.java:312) at com.jogamp.nativewindow.NativeWindowFactory.initSingleton(NativeWindowFactory.java:340) at com.jogamp.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1721) at com.jogamp.opengl.GLProfile.access$000(GLProfile.java:80) at com.jogamp.opengl.GLProfile$1.run(GLProfile.java:230) at java.base/java.security.AccessController.doPrivileged(AccessController.java:312) at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:216) at com.jogamp.opengl.GLProfile.getProfileMap(GLProfile.java:2297) at com.jogamp.opengl.GLProfile.get(GLProfile.java:988) at com.jogamp.opengl.GLProfile.get(GLProfile.java:1004) at com.mycompany.joglsecond.RawGL2ES2demo.main(RawGL2ES2demo.java:248) Command execution failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404) at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929) at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293) at org.apache.maven.cli.MavenCli.main (MavenCli.java:196) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:567) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) ------------------------------------------------------------------------ BUILD FAILURE ------------------------------------------------------------------------ Total time: 1.912 s Finished at: 2021-09-05T17:28:59+02:00 ------------------------------------------------------------------------ Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project JOGLsecond: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1] To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging. For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException I see in the import that GL2ES2 is used, OK I'm new to OpenGL and JOGL, but I know that GL4ES3 is available for import. Trying this gives the same error. I assume that this example is quite old, as I can see in the error message: libnativewindow_awt.so Why is nowerdays still AWT in use? |
Administrator
|
Administrator
|
In reply to this post by neblaz
Try to run this example with -Djava.awt.headless=true.
You can try my less modern example too: https://jogamp.org/wiki/index.php/Rudimentary_standalone_example_using_the_fixed_pipeline_by_Julien_Gouesse
Julien Gouesse | Personal blog | Website
|
Administrator
|
In reply to this post by neblaz
Examples not using AWT work, I use Adoptium OpenJDK 16 on my machine.
Julien Gouesse | Personal blog | Website
|
No virus scanner.
I tried as described in the RawGL2ES2demo.java * <p> * JOGL2 OpenGL ES 2 demo to expose and learn what the RAW OpenGL ES 2 API looks like. * * Compile, run and enjoy: wget http://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z 7z x jogamp-all-platforms.7z cd jogamp-all-platforms mkdir -p demos/es2 cd demos/es2 wget https://raw.github.com/xranby/jogl-demos/master/src/demos/es2/RawGL2ES2demo.java cd ../.. javac -cp jar/jogl-all.jar:jar/gluegen-rt.jar demos/es2/RawGL2ES2demo.java java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo * </p> with command java -Djava.awt.headless=true -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES2demo For a short fraction of a second a window appears but closes or better explained crashes with follwoing error in terminal: Exception in thread "main" java.lang.RuntimeException: com.jogamp.opengl.GLException: Profile GL4bc is not available on X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x7fbffc01faa0, owner true, ResourceToolkitLock[obj 0x17dcf4a, isOwner true, <737caba7, 40b9bbc0>[count 1, qsz 0, owner <main-Display-.x11_:0-1-EDT-1>]]], but: [GLProfile[GLES1/GLES1.hw], GLProfile[GLES2/GLES3.hw], GLProfile[GL2ES1/GLES1.hw], GLProfile[GL4ES3/GL4.hw], GLProfile[GL2ES2/GL4.hw], GLProfile[GL4/GL4.hw], GLProfile[GLES3/GLES3.hw], GLProfile[GL4/GL4.hw], GLProfile[GL3/GL4.hw], GLProfile[GL2GL3/GL4.hw]] at jogamp.newt.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:252) at jogamp.newt.DefaultEDTUtil.invoke(DefaultEDTUtil.java:165) at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:442) at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2782) at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1330) at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1335) at com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:578) at demos.es2.RawGL2ES2demo.main(RawGL2ES2demo.java:303) Caused by: com.jogamp.opengl.GLException: Profile GL4bc is not available on X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x7fbffc01faa0, owner true, ResourceToolkitLock[obj 0x17dcf4a, isOwner true, <737caba7, 40b9bbc0>[count 1, qsz 0, owner <main-Display-.x11_:0-1-EDT-1>]]], but: [GLProfile[GLES1/GLES1.hw], GLProfile[GLES2/GLES3.hw], GLProfile[GL2ES1/GLES1.hw], GLProfile[GL4ES3/GL4.hw], GLProfile[GL2ES2/GL4.hw], GLProfile[GL4/GL4.hw], GLProfile[GLES3/GLES3.hw], GLProfile[GL4/GL4.hw], GLProfile[GL3/GL4.hw], GLProfile[GL2GL3/GL4.hw]] at com.jogamp.opengl.GLProfile.get(GLProfile.java:991) at jogamp.opengl.GLContextImpl.verifyInstance(GLContextImpl.java:1471) at jogamp.opengl.GLContextImpl.setGLFunctionAvailability(GLContextImpl.java:1942) at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:395) at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:765) at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:648) at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:586) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1279) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759) at jogamp.opengl.GLAutoDrawableBase.defaultWindowResizedOp(GLAutoDrawableBase.java:260) at com.jogamp.newt.opengl.GLWindow.access$200(GLWindow.java:119) at com.jogamp.newt.opengl.GLWindow$2.windowResized(GLWindow.java:141) at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:4383) at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:4317) at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:1306) at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:1318) at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:145) at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375) X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 2/2, reusable (open, marked uncloseable): 0, pending (open in creation order): 2) X11Util: Open X11 Display Connections: 2 X11Util: Open[0]: NamedX11Display[:0, 0x7fbffc0024b0, refCount 1, unCloseable false] X11Util: Open[1]: NamedX11Display[:0, 0x7fbffc01faa0, refCount 1, unCloseable false] |
I'm not sure if it is relevant, but I have installed Mesa 3D:
glxinfo | grep OpenGL* OpenGL vendor string: Intel OpenGL renderer string: Mesa Intel(R) UHD Graphics 600 (GLK 2) OpenGL core profile version string: 4.6 (Core Profile) Mesa 21.1.4 OpenGL core profile shading language version string: 4.60 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL core profile extensions: OpenGL version string: 4.6 (Compatibility Profile) Mesa 21.1.4 OpenGL shading language version string: 4.60 OpenGL context flags: (none) OpenGL profile mask: compatibility profile OpenGL extensions: OpenGL ES profile version string: OpenGL ES 3.2 Mesa 21.1.4 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20 OpenGL ES profile extensions: Also recently sudo apt install libglfw3-dev |
Administrator
|
JogAmp doesn't use glfw.
Don't worry, I'm going to give it a try with OpenJDK 17. Please can you try with the latest release candidate of JOGL 2.4.0?
Julien Gouesse | Personal blog | Website
|
I can try, but how to add the two dependencies for 2.4.0?
At https://mvnrepository.com I cannot find 2.4.0, it is still 2.3.2. Or to try it with command line as before I need to know where to download 2.4.0 |
Administrator
|
You already know how to use the JogAmp fat JAR, just use it. Maven is very constraining, don't try to do everything with it.
https://jogamp.org/deployment/v2.4.0-rc-20210111/archive/jogamp-fat-all.7z
Julien Gouesse | Personal blog | Website
|
This post was updated on .
I downloaded the 2.4.0 fat jar and copied jogamp-fat.jar into the 2.3.2 jogam-all-platforms/jar folder to run almost the same command as before:
java -Djava.awt.headless=true -cp jar/jogamp-fat.jar:. demos.es2.RawGL2ES2demo Now I see an example running, some kind of a triangle (redish) acting like a pendulum on a magenta background. Still I would prefer having a Maven dependency. OK, development wie IDE but running the main class via command line. But debugging must be done via IDE, at least I have to do it that way. When will 2.4.0 finally be officially available, also in maven repository? Also I'm wondering why there is no dependecy for the jogamp-fat jar in maven repository? |
Administrator
|
We don't put snapshots into Maven Central. JOGL 2.4.0 is still a release candidate, not a release. The fat JAR helps to get the job done quickly, it's less error prone but it's a bit dirty.
Moreover, not using Maven doesn't prevent from debugging or running JOGL programs in an IDE, you can put the JogAmp fat JAR into the classpath, I do that often in NetBeans 12 and Eclipse 2021, it works like a charm. Finally, what you tried to do (i.e pointing to the fat JAR in your local file system) is doable with Gradle, I can show you how to do that, Gradle is supported by NetBeans and you'll be able to use Maven repositories in Gradle when JOGL 2.4.0 is released: https://jogamp.org/wiki/index.php?title=Setting_up_a_JogAmp_project_in_your_favorite_IDE#Gradle Keep in mind that we are volunteers.
Julien Gouesse | Personal blog | Website
|
This post was updated on .
Yes, I know that on such projects volunteers are involved.
I think the fat jar is not only a quick way but a very simple way for beginners with JOGL like me. Well, I'm used to Maven, Gradle not really. Adding the fat jar to classpath in NetBeans, OK will try that, never before, allways every dependency via pom.xml By the way, how to add jogamp-fat.jar into classpath of NetBeans Maven project? When I create a Java with Ant project, and add the jogamp-far.jar to Libraries, it functions immediately from within NetBeans 12.4 Why is it such a problem with a Java with Maven project to add local jar files? I tried again to add to pom.xml just to have the one local dependency: <dependencies> <dependency> <groupId>org.jogamp</groupId> <artifactId>jogamp-fat</artifactId> <version>2.4.0</version> <scope>system</scope> <systemPath>/home/me/PROGRAMs/JOGL/jogamp-fat/jogamp-fat.jar</systemPath> </dependency> </dependencies> It compiles, but Run File show following error: cd /home/me/NetBeansProjects/JOGLsecond; JAVA_HOME=/home/me/PROGRAMs/openjdk-16.0.2 M2_HOME=/home/me/PROGRAMs/apache-maven-3.8.2 /home/me/PROGRAMs/apache-maven-3.8.2/bin/mvn -Dexec.vmArgs= "-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}" -Dexec.executable=/home/me/PROGRAMs/openjdk-16.0.2/bin/java -Dexec.mainClass=com.mycompany.joglsecond.RawGL2ES2demo -Dexec.classpathScope=runtime -DskipTests=true -Dexec.appArgs= org.codehaus.mojo:exec-maven-plugin:3.0.0:exec Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts. Scanning for projects... Some problems were encountered while building the effective model for com.mycompany:JOGLsecond:jar:1.0-SNAPSHOT 'dependencies.dependency.systemPath' for org.jogamp:jogamp-fat:jar should use a variable instead of a hard-coded path /home/me/PROGRAMs/JOGL/jogamp-fat/jogamp-fat.jar @ line 20, column 25 It is highly recommended to fix these problems because they threaten the stability of your build. For this reason, future Maven versions might no longer support building such malformed projects. ----------------------< com.mycompany:JOGLsecond >---------------------- Building JOGLsecond 1.0-SNAPSHOT --------------------------------[ jar ]--------------------------------- --- exec-maven-plugin:3.0.0:exec (default-cli) @ JOGLsecond --- Error: Could not find or load main class com.mycompany.joglsecond.RawGL2ES2demo Caused by: java.lang.NoClassDefFoundError: com/jogamp/opengl/GLEventListener ... Is it because Maven complains now to use a variable or some other problem? |
Administrator
|
Yes, I agree with you, it's less error prone, I just have to tell the beginners to put it into the classpath and that's all.
I don't think that it will work in a NetBeans Maven project but it works in a NetBeans Java project: https://jogamp.org/wiki/index.php?title=Setting_up_a_JogAmp_project_in_your_favorite_IDE#NetBeans_IDE Another solution consists in fixing your try published on StackOverflow, remove {basedir}, try with an absolute path or a relative path. If you can, use a relative path. Look at this solution: https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project/51647143#51647143
Julien Gouesse | Personal blog | Website
|
Finally :)
One solution might be to first install the jar into local Maven repository, for example: mvn install:install-file -Dfile=/home/me/PROGRAMs/JOGL/jogamp-fat/jogamp-fat.jar -DgroupId=com.myjogampfat -DartifactId=jogamp-fat -Dversion=2.4.0 -Dpackaging=jar Then use it in pom.xml: <dependencies> <dependency> <groupId>com.myjogampfat</groupId> <artifactId>jogamp-fat</artifactId> <version>2.4.0</version> </dependency> </dependencies> Compiles and Run File runs the program. |
Administrator
|
It works but it requires an additional step. Have you tried adding "file:" in front of {basedir} and using the system scope?
Julien Gouesse | Personal blog | Website
|
You mean like
<dependency> <groupId>org.jogamp</groupId> <artifactId>jogamp-fat</artifactId> <version>2.4.0</version> <scope>system</scope> <systemPath>file:${basedir}/LIBs/jogamp-fat.jar</systemPath> </dependency> where LIBs is in project root? This doesn't compile. |
Administrator
|
Thank you for giving it a try, I'll try by myself as it would be a nice thing to have in order to improve our wiki so that the developers in the same situation than you can have a simple solution.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |