Hello Guest

The package org.lwjgl is not accessible in JavaSE-17 Eclipse IDE but work in 1.8

  • 0 Replies
Hi. sorry, I am a total newbie here; I was wondering why my code below works totally fine in my Eclipse Java project that uses JavaSE-1.8 but totally doesn't work in the project that uses JavaSE-17. I am totally lost here. it just said that the package is not accessible, I have been trying to find the answer anywhere on the internet and asking chat-gpt or bard doesn't produce any answer. Oh, and I use LWJGL 3.2.2 (I don't think it works with both versions of Java) and some random LWJGL folder I got from my university which I don't know the version (only works with JavaSE-1.8) Thank you in advance.

Code: [Select]
package Test;

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import org.lwjgl.*;
import org.lwjgl.Sys;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import org.lwjgl.system.*;
import static org.lwjgl.glfw.Callbacks.*;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.system.MemoryUtil.*;
import org.lwjgl.opengl.GLContext;

public class FirstOpenGLProgram
private static GLFWErrorCallback errorCallback;
private static long mWindowId;
private static float mClearColorRed = 0.1f;
private static float mClearColorGreen = 0.7f;
private static float mClearColorBlue = 1.0f;
private static float mClearColorAlpha = 0.0f;
private static String mWindowTitle = "First Program";
private static int mWindowWidth = 400;
private static int mWindowHeight = 300;

public FirstOpenGLProgram()
System.out.println( "LWJGL version: " + Sys.getVersion() );

public void init()
// register method for error messages
glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

// Initialize glfw
if (glfwInit() != GL_TRUE)
            throw new IllegalStateException("Unable to initialize GLFW");

// Set up Window Hints
glfwDefaultWindowHints(); // Load the default Window Hints

glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // The window will not be resizable
glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // Window will not be visible initially

// Get the size of the screen then calculate the centre.
ByteBuffer vidmode = glfwGetVideoMode( glfwGetPrimaryMonitor() );

int windowHorizOffset = (GLFWvidmode.width(vidmode)  - mWindowWidth)  / 2;
        int windowVertOffset  = (GLFWvidmode.height(vidmode) - mWindowHeight) / 2;
// code to set full screen
        //mWindowWidth = GLFWvidmode.width(vidmode);
//mWindowHeight = GLFWvidmode.height(vidmode);
        //mWindowId = glfwCreateWindow(GLFWvidmode.width(vidmode), GLFWvidmode.height(vidmode), "LWJGL3 - Coloured Triangle", glfwGetPrimaryMonitor(), NULL);
        // code for windowed window
        mWindowId = glfwCreateWindow(mWindowWidth, mWindowHeight, mWindowTitle, NULL, NULL);
        // set the windows position on the screen
        glfwSetWindowPos(mWindowId, windowHorizOffset, windowVertOffset);
        // Make the window visible
glfwMakeContextCurrent(mWindowId); // Make the glfw context current

GLContext.createFromCurrent(); // Generate an OpenGL context from the current glfw context

// set the Clear colour
glClearColor(mClearColorRed, mClearColorGreen, mClearColorBlue, mClearColorAlpha);
public void mainLoop()
// Run the rendering loop until the user has attempted to close
        // the window or has pressed the ESCAPE key.
while ( glfwWindowShouldClose(mWindowId) == GL_FALSE ){
// Clear the frame buffer

// Swap the color buffers 

// Poll for window events.

public void cleanUp()
// Destory the window created

// Release the error Call back

// terminate the glfw context

public static void main(String[] args)

// Create instance of our Lab
FirstOpenGLProgram  lab = new FirstOpenGLProgram();

// Initialise the lab

// Run the main loop

// Clean up after our lab
            // in case there was an exception terminate the GLFW context and release the call back function