IntelliJ Linux LWJGL 3 Add natives to - java

I wanted to try out the new LWJGL 3 which is currently in kind of a "beta"-state. Embarrassingly I can't even get the HelloWorld example (http://www.lwjgl.org/guide) to run.
package org.lwjgl.glfw does not exist
is all I get.
I added the lwjgl.jar and disruptor.jar to my module dependencies, but I guess I'm missing something about the natives here. I tried adding them as a lib, as a module (which tells me it's an empty library although there are two .so files in there oO)
I tried setting the -Djava.library.path of course, no success here:
-Djava.library.path=home/teolha/lwjgl-test/lib/natives/linux/x64
I tried invalidating caches, adding it as system lib and about everything I know. Still, the glfw package can't be found.
I'm not sure what I'm doing wrong, but I've never done this in IntelliJ 14, neither with lwjgl 3, so maybe something has completely changed here?
Any help appreciated!

Before anything else, I'm using LWJGL 3 NIGHTLY.
I've just managed to build and launch LWJGL 3's HelloWord. Does this help?
From lwjgl.org/guide:
Add the LWJGL jars to the classpath. This is usually done by setting up a library dependency for your project and attaching jars to it.
In my case, compiling with this worked
javac -cp ../jar/disruptor.jar:../jar/lwjgl.jar: -d . *.java
Set the -Djava.library.path system property (as a JVM launch argument) to the appropriate path for the target OS/architecture
And actually launching the tutorial worked with this.
java -classpath ../jar/disruptor.jar:../jar/lwjgl.jar: -Djava.library.path=../native/linux/x64/ org.lwjgl.demo.glfw.HelloWord
Be sure to adjust the path if needed.
edit: I just realized you were probably asking for a solution with intellij, in which case I'm not sure if this is helpful.

So, well, the error wasn't on my side.
LWJGL 3 is under heavy development currently and the latest stable version wouldn't match the example, thus I had to use the latest nightly.
(The api changed significantly)
My solution is:
Add the jars as libs and add the .so files as lib as well. That way you don't need to specify a library path argument :)
Works like a charm with the new lwjgl-api!

Related

Issue with JavaFX file in Intellij

I'm fairly new to using JavaFX and have been tinkering with it on my own in a few simple projects.
I have to collaborate with a few others for a main project, where I am seeing this conflicting issue:
I'm having an issue with the src.zip file of javafx. On my standalone projects, I do not encounter this issue. However, since working with others, this error has appeared. Prior to this, I was getting a Kotlin plugin issue, where I had to completely disable Kotlin.
Error:java: C:\Users\nolan\Javalibs\javafx-sdk-11.0.2\lib\src.zip
I'm unsure of what this issue might mean, so any help would be appreciated.
Thank you.
I had the same problem too and discovered it was because I added the JavaFX 11 SDK to Intellij incorrectly. I initially had the added library point to just the directory /lib. Since this directory includes both the jars and src.zip, Intellij will try to run both and produce the error.
To solve this, when Intellij prompts you to "Select Library Files," you need to explicitly select the files within the /lib directory which will then be added as shown here. This will also allow proper inspection of the source code without Intellij having to decompile the class file when ctrl + left clicking a class name.
Figured this out. I extracted the src.zip in the appropriate directory (deleting the zip as well), then had to change my VM Path to include:
--module-path "C:\yourpathto\javafx-sdk-11.0.2\lib;out\production" --add-modules=javafx.controls,javafx.fxml
I forgot to add ;out\production to the Module path.
A quick rebuild then solved this issue.

Launching an ImageJ plugin from NetBeans throws a JNI error. Launching it from ImageJ alone works fine

I have an ImageJ plugin and its sources which require a .dll library in order to operate. The plugin is working perfectly fine when I throw it int the ImageJ plugin folder, no problem.
But I have to modify the sources to add new features so I opened the project in NetBeans (it was already a NetBean project) and tried to start it from the IDE with a simple test class that start ImageJ and sets the plugin dir to the project dist\ dir. This works for all my other plugins but here I get an UnsatisfiedLinkError.
After some research and use of Dependency Walker I found out that I missed some .dll's in the project path. Now I have them all in the right places, executed with the -Djava.library.path="paths_to_all_my_libs" and I still get the error, Specific procedure not found.
It's really bothering me because I have to copy the .jar in dist to my ImageJ's installation, risking to mess things up and I can't use the console to output debugging stuff. Also I don't understand why I can't get it to work within NetBeans when everyting is fine with ImageJ alone.
Any idea is very welcome !
You can go with two approaches here:
make sure to add your dll location to PATH
if you don't care about location (e.g. you are developing something for your own), use exact location of dll by using System.load - it takes explicit location of library as argument

Java executable doesn't start

I'm having a frustrating issue with a java program I have been working on. I have not had this issue often in the past and I have actually created many versions using this same code and had no problems.
Suddenly, executable JARs of this program will not start. I have tried running them through the command prompt with Java and I get message about the main class not being found.
I have done a search here and none of the answers work for me. I have tried the following:
Removing the system library in the build path settings and adding it back. (The system library is [jre1.8.0_66]).
Changing the compliance settings from 1.7 to 1.6. I don't have an option for 1.8 and the JDK check box that says "Use compliance from execution environment on Java Build Path" is disabled.
Removing the main class and adding it back.
Using the package and export options for libraries.
I'm really not sure what else to do. I've tried doing a rebuild on the project many times and also tried restarting eclipse and re-exporting. I'm certain that I am selecting the main class when in the export preferences.
Any help or suggestions would be greatly appreciated as this has become very frustrating.
From the comments, it seems to me that you are not executing your JAR correctly. As stated in the comments, you are executing your JAR with java {jarname}. This syntax would only work with running a compiled Java class with a main method. To run a JAR, use:
java -jar {jarname}

Android update 17 seems incompatible with external Jars

I just allowed my Mac to do an update on its Java installation and now some of my old jars (like javax.mail and apache.commons.httpclient) are throwing "class not found" exceptions at run time!
Meaning, they compile fine, but then crash at run time with exceptions that look like this:
E/dalvikvm(2414): Could not find class 'javax.mail.internet.InternetAddress', referenced from method com.my.project.Main.isValidEmailAddress
Do I need to get more recent versions of the jars that have those classes? Or do I need to revert to my previous version of Java?
Or is this some totally unrelated problem that I'm just assuming has to do with the Java update (would be quite a coincidence, all of this worked perfectly prior to the update)?
crash at run time with exceptions that look like this:
Could not find class 'javax.mail.internet.InternetAddress', referenced from method com.my.project.Main.isValidEmailAddress
If you have problems with external jars, then:
create a folder named libs.
Copy and paste all needed external jar files into that folder.
It will automatically be included, as explained on this page: Dealing with dependencies in Android projects
Same thing happened to me but my folder was labeled "lib" instead of "libs" arg! updating was a little rough this time around... fixed after removing the external jars from the project settings and changing the folder to libs
If renaming the lib to libs doesn't work then try this.

Thinking in java library installation

Hi i've been trying to install the library on Thinking in Java book 4th edition and i hit a very thick brick wall. I've done everything that the guide from the website told me to do and i still can't get the library to work. From what i've read it seems that the problem is from the build.xml files. having no xml knowledge I am clueless about how I have to modify it in order for it to work. In both cmd and eclipse I am getting these error
c:\TIJ4\code\build.xml
Build Failed
c:\TIJ4\code\build.xml:59:J2SE5 required
Can anyone tell me what I should do ?
I am using eclipse if there is a simpler solution by using eclipse rather than ant please help me out. It's been a week now and I still can't make it work.
The important thing to do is to realize that your ant file has a specific java requirement.
Something to try that might fix this very easily : I believe you can remove any references to a specific JDK, and if you have a reasonably up to date JDK, the build will succeed.
The definete fix : Look into the exact (line 59) of your build file, and try to satisfy the java version that line requires. Java is generally backwords compatible -- something designed to run in J2SE5 should run in the latest JDK. Its not terribly difficult to update your JDK (just google for instructions on your OS).
The most common mistake I see is that people who have the java run time installed believe they also have the Java SDK as well.
Does this "install the library" means you want to look at the code and run them in your eclipse? If so I can share my experience with you.
First run the Eclipse.py script; this will add package info to the source code
Create a new Java project in Eclipse, and then just copy all the source code folders to the src source folder in eclipse, these folders will then be recognized as Java packages.
You should be able to run the classes with a main function.
You can also configure which java version to use for this project in Eclipse build path. 1.5 or higher will work.

Categories