How to add lwjgl3 to intelliJ project?

Started by codematic, December 17, 2016, 06:52:24

Previous topic - Next topic

codematic

Hi all! First and foremost I'm very new to intelliJ and just using IDE's in general. I've been trying to find an accurate tutorial of how to add lwjgl3 to my current project, but I just don't understand how. I'm trying to use it with a current LibGDX project I have.

I've followed the wiki here: http://wiki.lwjgl.org/wiki/Setting_Up_LWJGL_with_IntelliJ_IDEA.html

As well as online guides like this one:https://github.com/SilverTiger/lwjgl3-tutorial/wiki/Setup

However my issue is that everything I've seen deviates from each other one way or another, or the guides are out of date. For example I don't see matching files in any guide that are similar to the latest build available. Under the lwjgl options there is Maven, Gradle and Zip -- I'm not sure which one is best to use. I seem to have gradle files when using IntelliJ however I'm not quite sure what to do.

Please help! ???

spasi


mudlee

Hi! Didn't want to create a new thread because my problem is almost the same, but more specific.

  • I use OSX El Capitan
  • I use Intellij Idea Community Edition
  • In the Idea's Maven projects settings, under the profiles, lwjgl-natives-macos and lwjgl-natives-linux are checked

I've followed the lwjglbook tutorial so far and everything went fine, but at start I had some problem with the natives. Now, as 3.1.1 came out, I have the same problem again, so I'd like to clarify now what I'm doing wrong.

As I read the link you just wrote, I think use native jars is a must, but when I read the github doc (https://github.com/LWJGL/lwjgl3), I see
QuoteLWJGL extracts the natives to a temporary folder and loads them automatically, so no further configuration is necessary.

So what am I missing? Details below:

The problem is this:
[LWJGL] Version: 3.1.1 build 16
[LWJGL] 	 OS: Mac OS X v10.11.6
[LWJGL] 	JRE: 1.8.0_101 x86_64
[LWJGL] 	JVM: Java HotSpot(TM) 64-Bit Server VM v25.101-b13 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Found at: /var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16/liblwjgl.dylib
[LWJGL] 	Loaded from org.lwjgl.librarypath: /var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16/liblwjgl.dylib
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loading library: jemalloc
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Found at: /var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16/libjemalloc.dylib
[LWJGL] 	Loaded from org.lwjgl.librarypath: /var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16/libjemalloc.dylib
[LWJGL] MemoryUtil allocator: JEmallocAllocator
[LWJGL] Loading library: glfw
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Found at: /var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16/libglfw.dylib
[LWJGL] 	Loaded from org.lwjgl.librarypath: /var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16/libglfw.dylib
[LWJGL] Loading library: objc
[LWJGL] 	libobjc.dylib not found in org.lwjgl.librarypath=/var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16
[LWJGL] 	libobjc.dylib not found in java.library.path=/Users/mudlee/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
[LWJGL] 	Loaded from system paths
[LWJGL] Loading library (system): lwjgl_opengl
[LWJGL] 	liblwjgl_opengl.dylib not found in org.lwjgl.librarypath=/var/folders/qf/qblh3qgn5w98chzx393lq1yw0000gn/T/lwjglmudlee/3.1.1-build-16
[LWJGL] 	liblwjgl_opengl.dylib not found in java.library.path
[LWJGL] Failed to load a library. Possible solutions:
	a) Set -Djava.library.path or -Dorg.lwjgl.librarypath to the directory that contains the shared libraries.
	b) Add the JAR(s) containing the shared libraries to the classpath.
java.lang.NullPointerException
	at hu.mudlee.blockspot.Game.cleanup(Game.java:196)
	at hu.mudlee.blockspot.engine.GameEngine.cleanup(GameEngine.java:48)
	at hu.mudlee.blockspot.engine.GameEngine.run(GameEngine.java:43)
	at java.lang.Thread.run(Thread.java:745)
	at hu.mudlee.blockspot.engine.GameEngine.start(GameEngine.java:27)
	at hu.mudlee.blockspot.Main.main(Main.java:12)


VM arguments:
-XstartOnFirstThread -Dorg.lwjgl.util.DebugLoader=true -Dorg.lwjgl.util.Debug=true


My pom.xml (the core copied from the lwjgl generator):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>blockspot</groupId>
	<artifactId>blockspot</artifactId>
	<version>1.0-SNAPSHOT</version>

	<repositories>
		<repository>
			<id>snapshots-repo</id>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>

	<properties>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<lwjgl.version>3.1.1</lwjgl.version>
		<log4j.version>1.2.17</log4j.version>ââ,¬Â¨<joml.version>1.7.1</joml.version>ââ,¬Â¨<pngdecoder.version>1.0</pngdecoder.version>

	</properties>
	<profiles>
		<profile>
			<id>lwjgl-natives-linux></id>
			<activation>
				<os><family>unix</family></os>
			</activation>
			<properties>
				<lwjgl.natives>natives-linux</lwjgl.natives>
			</properties>
		</profile>
		<profile>
			<id>lwjgl-natives-macos></id>
			<activation>
				<os><family>mac</family></os>
			</activation>
			<properties>
				<lwjgl.natives>natives-macos</lwjgl.natives>
			</properties>
		</profile>
		<profile>
			<id>lwjgl-natives-windows></id>
			<activation>
				<os><family>windows</family></os>
			</activation>
			<properties>
				<lwjgl.natives>natives-windows</lwjgl.natives>
			</properties>
		</profile>
	</profiles>
	<dependencies>
		<dependency>ââ,¬Â¨	<groupId>org.l33tlabs.twl</groupId>ââ,¬Â¨	<artifactId>pngdecoder</artifactId>ââ,¬Â¨	<version>${pngdecoder.version}</version>ââ,¬Â¨</dependency>ââ,¬Â¨<dependency>ââ,¬Â¨	<groupId>org.joml</groupId>ââ,¬Â¨	<artifactId>joml</artifactId>ââ,¬Â¨	<version>${joml.version}</version>ââ,¬Â¨</dependency>ââ,¬Â¨<!-- https://mvnrepository.com/artifact/log4j/log4j -->ââ,¬Â¨<dependency>ââ,¬Â¨	<groupId>log4j</groupId>ââ,¬Â¨	<artifactId>log4j</artifactId>ââ,¬Â¨	<version>${log4j.version}</version>ââ,¬Â¨</dependency>

		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl</artifactId>
			<version>${lwjgl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-glfw</artifactId>
			<version>${lwjgl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-jemalloc</artifactId>
			<version>${lwjgl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-openal</artifactId>
			<version>${lwjgl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-opengl</artifactId>
			<version>${lwjgl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-stb</artifactId>
			<version>${lwjgl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl</artifactId>
			<version>${lwjgl.version}</version>
			<classifier>${lwjgl.natives}</classifier>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-glfw</artifactId>
			<version>${lwjgl.version}</version>
			<classifier>${lwjgl.natives}</classifier>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-jemalloc</artifactId>
			<version>${lwjgl.version}</version>
			<classifier>${lwjgl.natives}</classifier>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-openal</artifactId>
			<version>${lwjgl.version}</version>
			<classifier>${lwjgl.natives}</classifier>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-opengl</artifactId>
			<version>${lwjgl.version}</version>
			<classifier>${lwjgl.natives}</classifier>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.lwjgl</groupId>
			<artifactId>lwjgl-stb</artifactId>
			<version>${lwjgl.version}</version>
			<classifier>${lwjgl.natives}</classifier>
			<scope>runtime</scope>
		</dependency>
	</dependencies>
</project>

spasi

It looks like lwjgl-opengl-natives-macos.jar is not in the classpath. Have you checked if IntelliJ has resolved the updated Maven dependencies?

mudlee

I've just solved it right now, it was a strange Intellij Idea(?) kindof problem. After hours, I just deleted all idea related stuff, .idea dir, iml file, created a new project and recreated pom.xml again from sratch. It's so strange.
I've faced some similar problems with Idea in the past, but that was hard. For eg.: I wrote last week an if statement which was marked invalid by the editor, then typed the 100% same statement and deleted the old one, and it worked  ???

Anyways, it's working now.