所有我试图运行AWT并显示一个窗口。但是我得到了eclipse的JVM错误。错误如下:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (classFileParser.cpp:3174), pid=6688, tid=14480
# Error: ShouldNotReachHere()
#
# JRE version: 6.0_20-b02
# Java VM: Java HotSpot(TM) 64-Bit Server VM (16.3-b01 mixed mode windows-amd64 )
# An error report file with more information is saved as:
# C:\xampp\htdocs\android\FireRunn\hs_err_pid6688.log
这是运行该程序的实际代码。
import javax.media.opengl.*;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCapabilities;
public class Forest{//open forest
public static void main(String[] args)
{
Frame frame = new Frame("Hello World");
GLCapabilities glcapabilities = new GLCapabilities( );
GLCanvas glcanvas = new GLCanvas( glcapabilities );
frame.add(glcanvas );
frame.setSize(300, 300);
frame.setBackground(Color.WHITE);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
frame.setVisible(true);
}//close forest
}
}
});
答案 0 :(得分:1)
你似乎把你的右括号混淆了。这是应该起作用的最终代码:
public class Forest{//open forest
public static void main(String[] args) {
Frame frame = new Frame("Hello World");
GLCapabilities glcapabilities = new GLCapabilities();
GLCanvas glcanvas = new GLCanvas(glcapabilities);
frame.add(glcanvas);
frame.setSize(300, 300);
frame.setBackground(Color.WHITE);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});//close forest
frame.setVisible(true);
}
}