如何解决错误:找不到 com.jogamp.common.type.WriteCloneable 的类文件

huangapple go评论149阅读模式
英文:

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

问题

在编译JOGL代码时,我遇到了以下错误:

> 找不到 com.jogamp.common.type.WriteCloneable 的类文件

我还附上了错误的屏幕截图:
如何解决错误:找不到 com.jogamp.common.type.WriteCloneable 的类文件

以下是代码:

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();    
        // 画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();  
        // 画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);      
    }        
}
英文:

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:
如何解决错误:找不到 com.jogamp.common.type.WriteCloneable 的类文件

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.

答案1

得分: 0

你需要在编译您的类时包含[gluegen-rt库](https://jogamp.org/deployment/archive/rc/v2.4.0-rc-20200307/jar/gluegen-rt.jar)。

此外,您不需要解压缩jar文件。

使用`-cp`变量将一个jar库添加到您的[类路径](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/classpath.html):

```shell
javac -cp .:gluegen-rt.jar:jogl-all.jar HelloWorld.java

要运行您的示例,您还需要本机扩展。您可以在此处找到它们。

注意:特别是在使用最新的Mac OS版本时,请使用最新的JOGL库。

java -cp .:gluegen-rt.jar:jogl-all-natives-macosx-universal.jar:jogl-all.jar:gluegen-rt-natives-macosx-universal.jar HelloWorld

这是输出:

<img src="https://i.stack.imgur.com/xKtmH.png" width="250" />


<details>
<summary>英文:</summary>
You need to include [gluegen-rt lib](https://jogamp.org/deployment/archive/rc/v2.4.0-rc-20200307/jar/gluegen-rt.jar) to compile your class.
Also, you don&#39;t need to unzip jar files.
Use `-cp` variable to add a jar library to your [classpath](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/classpath.html):

javac -cp .:gluegen-rt.jar:jogl-all.jar HelloWorld.java


To run your example you also need native extensions. You can find them [here](https://jogamp.org/deployment/archive/rc/v2.4.0-rc-20200307/jar/) 
**Note**: Use the latest JOGL libraries especially if you use the latest Mac OS version.

java -cp .:gluegen-rt.jar:jogl-all-natives-macosx-universal.jar:jogl-all.jar:gluegen-rt-natives-macosx-universal.jar HelloWorld


Here is the output:
&lt;img src=&quot;https://i.stack.imgur.com/xKtmH.png&quot; width=&quot;250&quot; /&gt;
</details>
# 答案2
**得分**: 0
下载 jogamp-fat.jar 文件 [这里][1](这是2020年10月的最新发行候选版本,否则,请在 JOGL 2.4.0 或以后的版本发布时使用 [这个][2],通常情况下会更近一些)。
编译使用以下命令:
```shell
javac -cp .:jogamp-fat.jar HelloWorld.java

运行使用以下命令:

java -cp .:jogamp-fat.jar HelloWorld

你可以在我们的官方维基 这里 找到更多信息。Windows 用户需要将 : 替换为 ;。使用这个大型 JAR 文件更容易且对新手来说错误更少,它包含了所有 JogAmp API(JOGL、JOCL、JOAL 和 GlueGen)的 Java 库和本地库。

英文:

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).

huangapple
  • 本文由 发表于 2020年10月4日 01:58:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/64187329.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定