Hot questions for Using Lightweight Java Game Library in eclipse

I am new with OpenGL. I have just installed LWJGL and created a User Library in Eclipse. It is linked to my Project but what Eclipse won't do is to import the needed classes automatically. Is there a way to get it work? I don't like to write (e.g.) GL30.glMethodName() every time and I also don't like to make a static import like import static org.lwjgl.opengl.GL30.* (which is bad practice).

Answer:

Open the preferences window with Window -> Preferences.

Go to Java -> Editor -> Content Assist -> Favorites.

Click New Type....

Enter org.lwjgl.opengl.GL11.

Do steps 3 and 4 for each GL** class.

When you now enter something like glGenVertexArrays(); and hover your mouse over it, there is an option Add static import for 'GL30.glGenVertexArrays'. Select it to add the import.

Additionally, you can now type something like glGenVertex and press Ctrl+Space to get a popup menu of available methods. Selecting one of them automatically adds the import.

But it always throws the same error, no matter if I add the native files or not.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at tools.crystalcoffee.methods.DisplayMethod.createDisplay(DisplayMethod.java:11)
at tools.crystalcoffee.methods.DisplayMethod.main(DisplayMethod.java:38)

I have looked everywhere for an answer, for 2 hours straight and thats ALL it throws. Help?

Answer:

Check your properties for lwjgl. I tried your program and first I got the same error (Unsatisfied link). Then if I make sure that all libraries are lwjgl 2.9.3 (get it from the legacy.lwjgl), then it works and the display starts rendering.

The exception we had seems to be becuase we had mixed versions of lwjgl 3 and 2.

See also LWJGL Display class can't be found

And Getting 'java.lang.UnsatisfiedLinkError': no lwjgl in java.library.path

I receive the error, "The import org cannot be resolved". Even though I've added the files to the build path config and I've added the native path in there as well. I've looked at this similar question and effectively tried every proposed solution. I've also tried deleting the project and reinstalling the dependencies. Here is my file tree for reference:

I'd be highly grateful if you could show me what I've done wrong. Thanks so much.

Edit 1:

I've discovered something interesting concerning the line:

Display.setDisplayMode(new DisplayMode());

While both Display and DisplayMode are underlined in red because the import is not working above, one of the "quick fixes" that comes up (even if I delete the import statements) is:

Import 'Display' (org.lwjgl.opengl)

Clicking this writes the import statement at the top (if it isn't there) or brings the cursor to it (if it is there). It then throws the aforementioned error. This seems to indicate that it does actually recognize the fact that the libraries are there, but for some reason can't import them.

The plot thickens.

Edit 2:

To check whether the problem is specifically to do with compatibility with lwjgl2 I've tried importing a class from another library (a linear algebra library called "jblas") with:

import org.jblas.Info;

...but once again I receive the same error. I guess this indicates that the problem is with the way that I am adding the scripts to the build path, with the software itself or a combination thereof.

I can import the built-in packages and I can import packages that I've made.

Answer:

EDIT: DON'T DO THE FOLLOWING: LOOK AT THE EDIT
I downgraded my eclipse version to Oxygen, now I can import the packages without errors. Hopefully, this is remedied eventually so that I can move to the latest version of eclipse. Also, even in oxygen, it didn't work at first. I created a new project and reimported the various jars.

Edit: I faced this problem again, in oxygen

Fortunately this time I resolved it more quickly. I simply added the following snippet to my module-info.jar:

requires org.lwjgl;

Yep it was that simple.

was probably the problem the first time as well. This second problem arose from a second project I decided to make. The last project didn't have a module-info.jar.

That's why it allowed me to not write that line. Meanwhile, the original projects in eclipse 2018/19 did have the module-info.jar file and did have the problem. Maybe in Oxygen it just doesn't happen by default?

Every time I look online the download is not in the same format as the current version, which leads to following the instructions and not being able to use the libraries I need. I'm new to lwjgl but fluent in java if someone could help me set up lwjgl I would be every appreciative. More specifically, the download is not broken up into folders like many that I see in tutorials.

every time i try running my java project through eclipse (I use the lwjgl lib so i create a window) the window appears , freezes , then it's not responding
it's not a code problem i tried a very basic code like

Unanswered Questions

We will update and show the full solutions if these questions are resolved.

Fixing Incompatibility Between LWJGL 3 and Slick-Util

What I am trying to do is map a texture to an OpenGL model within LWJGL. I know that LWJGL 3 and slick-util sometimes work together and sometimes don't. In my case, it works a little and then tries to ...

LWJGL Java App Only Launches By Terminal (Linux, potentially OS X)

I have an application I've created using LWJGL with two main components: a game and an editor. When running the jar by eclipse or using java -jar <jarname>.jar, the application runs the LWJGL ...

“no lwjgl in java.library.path”

In looking around and reading other similar posts, I've been unable to solve a problem I've been having with LWJGL as a dependency. I'll try to be as descriptive and informative as possible, so thank ...