Java程序不会在eclipse中作为应用程序运行

时间:2013-08-05 00:51:46

标签: java eclipse

我刚刚开始使用Java和Eclipse,我遇到了一个问题。我将一个程序复制为YouTube类的一部分来创建棋盘格。它作为applet运行,但不作为应用程序运行。当我尝试作为应用程序运行时,我得到:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Clay\GCMDLN.DLL: Can't load IA 32-bit .dll on a AMD 64-bit platform at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary1(Unknown Source) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.load0(Unknown Source) at java.lang.System.load(Unknown Source) at acm.program.DOSCommandLine.getCommandLine(Program.java:2268) at acm.program.Program.getCommandLine(Program.java:1477) at acm.program.Program.main(Program.java:1207)

以下是代码:

/* File CheckerBoard.java
 * ----------------------
 * This program creates a checkerboard
 */

import acm.graphics.*;
import acm.program.*;

/* This class draws a checkerboard on the graphics window. 
 * The size of the checkerboard is determined by the
 * constants NROWS and NCOLUMNS, and the checkerboard fills
 * the verticle space available.
 */

public class CheckerBoard extends GraphicsProgram {
    /* Number of rows */
    private static final int NROWS = 8;

    /* Number of columns */
    private static final int NCOLUMNS = 8;


    /* Runs the program */
    public void run() {
        int sqSize = getHeight() / NROWS;
        for (int i = 0; i < NROWS; i++) {
            for (int j = 0; j < NCOLUMNS; j++) 
                        {
                int x = j * sqSize;
                int y = i * sqSize;
                GRect sq = new GRect (x, y, sqSize, sqSize);
                sq.setFilled(((i + j) % 2) != 0);
                add (sq);
            }
        }
    }
}

谢谢!

2 个答案:

答案 0 :(得分:2)

您正在尝试将32位DLL加载到64位处理器中。

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Clay\GCMDLN.DLL: 
    Can't load IA 32-bit .dll on a AMD 64-bit platform at java.lang.ClassLoader$NativeLibrary.load(Native Method) 

查看错误,您的JVM是64位,但DLL GCMDLN.DLL32-bit处理器的buit。你也可以,

  • 获取64位GCMDLN.DLL
  • 使用GCMDLN.DLL安装和使用32位JVM

答案 1 :(得分:1)

Applet有不同的生命周期方法,即 - 它们不是通过调用main()开始的,因此您将无法通过IDE运行它,至少不是通过单击run。

在Eclipse中,右键单击您的项目,尝试运行配置&gt;以Applet身份运行。