Hot questions for Using Lightweight Java Game Library in jar

I'm developing a game with LWJGL 3.0.0a. Many tutorials out there use the lwjgl_util.jar that contains stuff like Vector2f and GLU for functions like gluUnProject.

In this version though (available on the downloads page) there is no such library contained anymore; it only contains the core lwjgl.jar. Where have these utils gone?

Answer:

LWJGL 3 has the focus on the OpenGL bindings. On the wiki it is stated

The library includes functionality and APIs that simply should never have been added to it. Such functionality belongs either to an engine using LWJGL, or to another library layered on top of LWJGL. This includes the util package (vecmath, mapped objects, image/sound file readers, etc) and anything to do with applets.

So essentially this means that, at least for the moment, there will not be any Util package in the core library.

However, there are plans of including one when the other core features (OpenGL ES bindings, Vulkan bindings etc.) have been implemented.

[.x] Official utility library.

Even though the focus for LWJGL 3 is to only include the very lightweight, lower-level functionality in the core library, ease-of-use and appeal to novice programmers is also important. The current plan is to start a sibling project that will create an official utility library for LWJGL 3. It will include all non-essential functionality, optional features and helper/convenience utilities. It may also include an API that matches LWJGL 2 for easy porting of existing code. Engine-level functionality, like vecmath and fixed-function simulation, may or may not be included, depending on the amount of support the project receives. Another option is the creation of "profile-based" OpenGL classes, e.g. a GLCore class that includes only the core profile functionality from GL11 up to GL31.

I am following along with a tutorial book on LWJGL3 and I tried to make my own image loading code (The book code does not use the STB library) and it works perfectly fine when the project is run normally (IntelliJ IDE, run directly from the build folder), It loads the image from into the ByteBuffer and stbi_load_from_memory works fine, but as soon as it is compiled and put in a jar file it just stops working, Even tho the image was successfully loaded into the ByteBuffer, as if the stbi_load_from_memory function just returns null if it's in a Jar.

It can't be a misspelled file name or recourse path, because it loads the data into the array properly no matter if it's a jar or not.

Additional Information:

Java version: 1.8.0_131 64bit

Processor architecture: amd64

IDE version (if needed for some reason): IntelliJ 2017.1.4 Ultimate

OS: Ubuntu 16.04 LTS 64 bit

Kernel: Linux 4.8.0-58-generic amd64

LWJGL version: 3.1.2

The project is made in Gradle 3.3

if required i will upload and post the link of the entire source code

Answer:

The problem is probably in your imageFile.available(). The available method of InputStream is not a good way to get the size of the stream; in fact you can't get the size of the stream, you have to read it until it ends.

What you want to do is convert your InputStream to a byte array. Look here how to do that: link.
The rest of the code should be OK. Note that you need a direct ByteBuffer, so wrapping the byte array will not work, but you are already using the correct method (BufferUtils.createByteBuffer).

I am working on a LWJGL game engine. I want to export the engine as a JAR file that can be utilized in the build path of other projects. I tried using JarSplice to pack in all of the natives, but I am still getting an error when I try to use the engine packed in a jar in a different project.

When I export the engine as a JAR, move it to the build path of another project, and try to run, I am getting an UnsatisfiedLinkError when the JAR engine tries to create an OpenAL instance with AL.create(). From what I'm reading, this is an error with the natives, though I could be wrong in this instance.

How can I export my engine as a jar so it can be used in other projects?

Answer:

With LWJGL 2.x the user of your engine will always have to manually add the natives to the game's native path. They will not get extracted automagically from jar files. The current LWJGL 3 on the other hand provides such functionality and allows you to distribute your engine together with the LWJGL dependency as a jar file. It does this by searching the classpath for the native files and extracting them to a temporary folder and loading them there.

You should define a property for ${lwjgl.version}. As you can see at Maven Central, the only version of this artifact is 3.0.0 and you must explicitly define it. Please replace your <properties> tag with the following:

I'm using LWJGL and OpenGL. My program works in Eclipse, but when I export it I get a java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path.

Can someone help me export the jar with the lwjgl files?

Answer:

If you looked at LWJGL wiki you would know that you need to define where native libraries are located. In Eclipse you can configure them for every individual JAR file, so it is easy to forget that it is necessary to pass additional arg when running from command line

This should be a pretty simple question. I am trying to us LWJGL and I watched a tutoiral on how to get started but the import statements and all lwjgl code is getting error messages. The file is below. What am I doing wrong? I added the jar in properties but it is still not working.

After exporting my game to jar it does not work.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jinput-dx8_64 in java.library.path

I read that I have to put the files anywhere in my computer and add the .dll files path to java.libraty.path, but, will it work if I try the game in another computer?

Tanks :D

Answer:

If you are working on windows, just add the path of the dll file along with the java path in environment variable. For example. If your dll file is present in jdk/jre/bin,path=C:\Program Files\Java\jdk1.8.0_25\jre\bin. Just try this one. Once worked for me.

Unanswered Questions

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

Exporting to a exe with jarsplice

I am making a game using lwjgl, and am trying to figure out how to export it into a single runnable jar or exe.I saw that i can use jarsplice to make exe's fairly easily so i followed the ...

Resource loading in external jars not working

I'm making a game using LWJGL and Slick2d, and naturally have game assets to export in my jar to use. However, they fail to load from within the runnable .jar I create using jarsplice, but will run ...

Maven copies folder content at the root of jar when generating

Good evening,I'm creating a Java project and tries to build it with maven. The project needs LWJGL libraries, also, I added concerned dependencies in my pom.xml. However, I also need to include ...