1

I'm trying to work my way through ThinMatrix's Open Gl Java tutorial. And... I'm stuck on video 1. I also worked through the short precursor video where he installed on the dependencies (Including lwjgl 2) in eclipse. Right now I just have the very start of the first class:

package renderEngine;
import org.lwjgl.opengl.Display; //Error is here
import org.lwjgl.opengl.DisplayMode; //And here
//Handle the window
public class DisplayManager {
    //Create a display
    public static void createDisplay() {
        Display.setDisplayMode(new DisplayMode());
    }
}

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:

enter image description here

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.

To clarify how I put things on the build path:

Right click project name -> click "build path" -> click "configure build path" -> click "libraries" -> click on eiether "module path" or "class path" (I've tried both) -> click "add jars" -> navigate to my "lib" folder -> go inside "jars" folder -> select all the jars -> click "apply and close".

Edit 3:

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

PolymorphismPrince
  • 307
  • 1
  • 4
  • 14
  • I see Java 10, I have this aching feeling that somehow modules are making the LWJGL stuff invisible to your code somehow. – Gimby Oct 11 '18 at 11:12
  • i would make sure first of all that you have only one jdk installed. – Sir. Hedgehog Oct 11 '18 at 11:16
  • @Sir.Hedgehog, when I write `java -version` in terminal it shows me three versions: "java version", "java(tm) SE runtime environment" and "Java HotSpot(TM) 64-Bit Server VM". Does that indicate only one jdk? Do I have to go somewhere else to tell? – PolymorphismPrince Oct 11 '18 at 20:41
  • @Gimby See **Edit 2**, I've tried using other libraries but had the same problem. – PolymorphismPrince Oct 11 '18 at 21:29
  • @PolymorphismPrince try to find a way to make your iDE see only one jdk the one you want. you can specify that i believe in the IDE or if not possible you can do it from your system properties for which you need to google more, and always if you get unknown to u erros, google the erros. sometimes it helps – Sir. Hedgehog Oct 12 '18 at 06:30
  • @Sir.Hedgehog I checked the jdks in eclispe and there is only one. – PolymorphismPrince Oct 12 '18 at 07:12
  • @PolymorphismPrince then good luck following the stack trace and googling the errors given – Sir. Hedgehog Oct 12 '18 at 07:14

1 Answers1

0

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?

PolymorphismPrince
  • 307
  • 1
  • 4
  • 14
  • *"Also, even in oxygen, it didn't work at first. I created a new project and reimported the various jars."* - yeah, so it had nothing to do with Eclipse but it was a wonky project setup. Try opening this newly created project in the latest version of Eclipse to see what happens. – Gimby Oct 15 '18 at 11:38
  • @Gimby Yes but I created several projects in Eclipse 18/19. None of them worked. – PolymorphismPrince Oct 16 '18 at 00:19
  • @Gimby if you're interested, look at my edited answer. I worked out the actual culprit of the problem. – PolymorphismPrince Oct 22 '18 at 05:22