简体   繁体   中英

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

HelIo i am trying to make a game engine and right now to create a window with it but there is an error

I included the librarys slack-util and lwjgl before you ask me

The error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void 
org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'
at org.lwjgl.opengl.WindowsDisplay.setWindowProc(Native Method)
at org.lwjgl.opengl.WindowsDisplay.<clinit>(WindowsDisplay.java:218)
at org.lwjgl.opengl.Display.createDisplayImplementation(Display.java:159)
at org.lwjgl.opengl.Display.<clinit>(Display.java:136)
at com.firenet.engine.Window.createWindow(Window.java:11)
at com.firenet.engine.MainComponent.main(MainComponent.java:11)

Window.java:

package com.firenet.engine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class Window 
{
    public static void createWindow(int width, int height, String title)
    {
         Display.setTitle("Test!");
         try 
         {
         Display.setDisplayMode(new DisplayMode(width, height));
         Display.create();
         } 
         catch (LWJGLException e) 
         {
             e.printStackTrace();
         }
      }
   }

MainComponent.java:

package com.firenet.engine;

public class MainComponent 
{
     public static final int width = 600;
     public static final int height = 500;
     public static final String title = "Test!";

     public static void main(String[] args)
     {
         Window.createWindow(width, height, title);
     }
}

Your problem seems to be that you have not added the "native" folder to your build path. I have created a project based on the code that you mentioned in the question. After adding the 'natives' correctly I ran your code, and it shows me a blank black window which closes after some time. Try the following:

  1. In your project (I am using Eclipse) go to JRE System Library > Build Path > Configure Build Path (by right clicking on JRE System Library)

配置构建路径

  1. Next Select Java Build Path > Libraries (tab) > Native Library Location . Now press 'Edit'

编辑本机库部分

  1. The next step is OS specific. In your download of lwjgl there is a directory 'native'. Select the folder based on the OS you are using. For example if you are using Windows then select lwjgl-2.xx > native > windows . Now I am on a macOS so I will be using the one for mac.

为您的操作系统添加本机

After this run your application and hopefully you will see a blank window like I see when I run it on my machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM