Search code examples
javajogl

How to solve error class file for com.jogamp.common.type.WriteCloneable not found


While compiling JOGL code, I am getting following error

class file for com.jogamp.common.type.WriteCloneable not found

I also attached a screenshot of the error: screenshot with console with error message "class file for com.jogamp.common.type.WriteCloneable not found"

Here is the code:

package com.jogamp.opengl;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;   
import javax.swing.JFrame;    
    
public class HelloWorld implements GLEventListener {    
    
    @Override    
public void init(GLAutoDrawable arg0)     
  {    
            
  }    
    
   @Override    
public void display(GLAutoDrawable drawable) {    
final GL2 gl = drawable.getGL().getGL2();    
  //Draw H  
gl.glBegin(GL2.GL_LINES);   
gl.glVertex2d(-0.8, 0.6);  
gl.glVertex2d(-0.8, -0.6);  
gl.glVertex2d(-0.8, 0.0);  
gl.glVertex2d(-0.4, 0.0);  
gl.glVertex2d(-0.4, 0.6);  
gl.glVertex2d(-0.4, -0.6);  
gl.glEnd();  
//Draw W  
gl.glBegin(GL2.GL_LINES);  
gl.glVertex2d(0.4,0.6);  
gl.glVertex2d(0.4,-0.6);  
gl.glVertex2d(0.4,-0.6);  
gl.glVertex2d(0.6,0);  
gl.glVertex2d(0.6,0);  
gl.glVertex2d(0.8,-0.6);  
gl.glVertex2d(0.8,-0.6);  
gl.glVertex2d(0.8,0.6);  
gl.glEnd();  
   }          
   @Override    
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)     
   {        
    
   }    
   @Override    
public void dispose(GLAutoDrawable arg0)     
   {    
    
   }    
    
public static void main(String[] args) {    
    
final GLProfile gp = GLProfile.get(GLProfile.GL2);    
GLCapabilities cap = new GLCapabilities(gp);    
    
final GLCanvas gc = new GLCanvas(cap);    
HelloWorld sq = new HelloWorld();    
gc.addGLEventListener(sq);    
gc.setSize(400, 400);    
    
final JFrame frame = new JFrame("Hello World");    
frame.add(gc);    
frame.setSize(500,400);    
frame.setVisible(true);      
   }        
}    

Please help me resolve this issue.

Note: I downloaded jogl-all.jar file. Then I unzipped it. Then written the code above.


Solution

  • Download jogamp-fat.jar here (it's the latest release candidate in October 2020, otherwise, take this one when it becomes more recent, typically when JOGL 2.4.0 or any later version is released).

    Compile with:

    javac -cp .:jogamp-fat.jar HelloWorld.java
    

    Run with:

    java -cp .:jogamp-fat.jar HelloWorld
    

    You can find much more information in our official wiki here. Windows users must replace : by ;. Using the fat JAR is easier and less error prone especially for newbies, it contains both the Java libraries and the native libraries of all JogAmp APIs (JOGL, JOCL, JOAL and GlueGen).