I want to write an application that runs with two different windows, one with JavaFX (v18) and one with Processing (v4). I'm on Linux 64-bit using IntelliJ-Idea as IDE and Maven to manage dependencies. The project is created as a JavaFX project and the processing.core
library is added as a separate project library.
I spent A LOT of TIME understanding how to set up the project correctly and I succeeded in launching a simple JFX app that creates a new window where a 2D sketch runs fine (a circle that follows the mouse's coordinates).
The problem comes out when I try to launch a 3D sketch (because that's what i need for my application) with the P3D render and I receive an exception with:
java.lang.UnsatisfiedLinkError: Can't load library: /home/.../natives/linux-amd64/libgluegen_rt.so
As suggested here I already tried to solve adding the jogl-fat.jar
library as a project's library or dependencies for the jogl libraries from maven, without effects.
I don't think that something is wrong with my code but it's Processing or JFX's fault. PS: I have to use processing to make a 3D environment for simulation, but I don't have restrictions for JavaFX. If someone knows another framework that can let me launch a P3D sketch and interact with it with some controls (i.e. buttons), you are welcome!
This is an example of the java classes that I have:
public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
public class ProcessingTest extends PApplet{
private PeasyCam cam;
@Override
public void setup() {
background(255);
cam = new PeasyCam(this, 400);
}
public void settings(){
size(200, 200, P3D);
}
public void draw(){
background(255);
rotateX(-.5f);
rotateY(-.5f);
lights();
scale(5);
strokeWeight(1 / 10f);
fill(96, 255, 0);
box(30);
pushMatrix();
translate(0, 0, 20);
fill(0, 96, 255);
box(5);
popMatrix();
}
public void run(){
String[] args = {"com.effibot.provafx.ProcessingTest"};
PApplet.runSketch(args,this);
}
}
public class HelloController {
@FXML
private Label welcomeText;
private ProcessingTest pt;
@FXML
protected void onHelloButtonClick() {
welcomeText.setText("Welcome to JavaFX Application!");
pt = new ProcessingTest();
pt.run();
}
}
CodePudding user response:
Unfortunately I don't have experience with your exact setup (64-bit Linux, IntelliJ, JavaFX application), but hopefully I can point you in the right direction.
The OpenGL native libraries should ship with Processing:
processing-4.0b8-linux-x64.tar/processing-4.0b8/core/library/linux-amd64
should contain:
libgluegen_rt.so
libnativewindow_awt.so
libnativewindow_drm.so
libnewt_head.so
libnativewindow_x11.so
libjogl_desktop.so
libnewt_drm.so
libjogl_mobile.so
Hopefully the IntelliJ docs can help with the native library setup. The idea is that you'd tell IntelliJ not only to use core.jar, jogl-all.jar and gluegen-rt.jar but also set the native library paths to point to the .so files.
(as jewelsea mentions, in the run options you could set the native path as a command line argument (e.g. if Processing in unzipped in the home folder -Djava.library.path=/home/processing-4.0b8-linux-x64.tar/processing-4.0b8/core/library/linux-amd64
) but I hope IntelliJ's interface is straight forward enough to easily allow you to set the native library path for the gluegen and jogl libraries)
(Also, bare in mind Processing ships with it's own JDK packaged (in processing-4.0b8/java
): in case you run into some java version related issues you could switch the JDK in IntelliJ))