我想在Mountain Lion上設置JOGL。我想使用它沒有像Eclipse或者IDE這樣的IDE。但我無法完成它的工作。Mountain Lion上的JOGL設置
我所做的:
- 下載最新從這裏JOGL建設:http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL#Downloading_the_latest_automatic_build
- 把文件JOGL-所有本地人,MacOSX的-universal.jar - gluegen-java-src.zip - JOGL -all.jar - gluegen-rt-natives-macosx-universal.jar - jogl-java-src.zip - gluegen-rt.jar(就像它在上面的鏈接中描述的一樣,至少我是這樣理解的)目錄:〜/ jogl
- 下一步:配置類路徑。在我的系統上,此時CLASSPATH變量爲空。所以我用自己的全名添加了我的jar,比如export CLASSPATH = $ CLASSPATH:〜/ jogl/gluegen-rt-natives -macosx-universal.jar:〜/ jogl/...
- 試圖編譯測試代碼。錯誤:javax.media.opengl不存在
- 嘗試更改類路徑以匹配所有具有通配符「*」的文件 - >相同問題
- 試圖用javac -classpath進行編譯「〜/ jogl/*」源的.java,同樣的錯誤
- 添加的所有文件seperately到javac的-classpath,同樣的錯誤
這個問題或許非常簡單和明顯的解決,但我不會在這裏問,如果我沒試過幾乎所有的東西得到它工作!
下面是測試代碼我使用:
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;
public class test
{
public static void main(String[] args)
{
// setup OpenGL Version 2
GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities capabilities = new GLCapabilities(profile);
// The canvas is the widget that's drawn in the JFrame
GLCanvas glcanvas = new GLCanvas(capabilities);
glcanvas.addGLEventListener(new Renderer());
glcanvas.setSize(300, 300);
JFrame frame = new JFrame("Hello World");
frame.getContentPane().add(glcanvas);
// shutdown the program on windows close event
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
});
frame.setSize(frame.getContentPane().getPreferredSize());
frame.setVisible(true);
}
}
我的系統: - OSX 10.8.2 - 的javac 1.6.0_35
只有gluegen-rt.jar和jogl-all.jar必須位於類路徑中。包含JOGL 2.0和GlueGen的本地庫的JAR必須位於相同的目錄中,但不在類路徑中。 – gouessej