0

I want to develop an application on Netbeans IDE, with JavaFX and work on remote mode with my RaspberryPi3.

What I have done

  1. Installed jdk 1.8 with sudo apt install openjdk-8-jdk
  2. Installed last version of JavaFX Embedded SDK port, changing these files:
    armv6hf-sdk/rt/lib/ext/jfxrt.jar -->jre/lib/ext/
    armv6hf-sdk/rt/lib/arm/* --> jre/lib/arm/
    armv6hf-sdk/rt/lib/javafx.platform.properties --> jre/lib/
    armv6hf-sdk/rt/lib/javafx.properties --> jre/lib/
    armv6hf-sdk/rt/lib/jfxswt.jar --> jre/lib/
  3. Installed librxtx lirarie with sudo apt-get install librxtx-java
  4. On netbeans IDE, I used remote platform with JRE Path /usr

The application (It's just a HelloWorld)


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JavaFXApplication2 extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
        
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        
        Scene scene = new Scene(root, 300, 250);
        
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
}

Verbose OutPut

SEVERE [global]
java.lang.NullPointerException


    at org.netbeans.modules.java.j2seembedded.project.Utilities.getTargetOSForRP(Utilities.java:326)
    at org.netbeans.modules.java.j2seembedded.project.RemoteBuildPropertiesProvider.createAdditionalProperties(RemoteBuildPropertiesProvider.java:95)
    at org.netbeans.modules.javafx2.project.JFXActionProvider.collectAdditionalBuildProperties(JFXActionProvider.java:294)
    at org.netbeans.modules.javafx2.project.JFXActionProvider.invokeAction(JFXActionProvider.java:185)
    at org.netbeans.spi.project.support.LookupProviderSupport$MergedActionProvider.invokeAction(LookupProviderSupport.java:271)
    at org.netbeans.modules.project.ui.actions.ProjectAction$2.run(ProjectAction.java:186)
    at org.openide.util.Mutex.doEvent(Mutex.java:1356)
    at org.openide.util.Mutex.writeAccess(Mutex.java:462)
    at org.netbeans.modules.project.ui.actions.ProjectAction.runSequentially(ProjectAction.java:183)
    at org.netbeans.modules.project.ui.actions.MainProjectAction$1$1.run(MainProjectAction.java:140)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)    
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

The result
If I build it with the Proyect platform, I can normally develop my application, then copy the .jar to the raspberry using Filezilla and then execute on the raspberry.
But I can't work remotely. When I select the Pi as platform, It doesn't show anything on console and it only appears one notify saying "java.lang.NullPointerException". By the way, this is my first post

Result on Netbeans 8.2 and Apache NetBeans 12.0

  
Error: no se ha encontrado o cargado la clase principal javafxapplication1.JavaFXApplication1  
Causado por: java.lang.NoClassDefFoundError: javafx/application/Application
C:\Users\manol\Documents\NetBeansProjects\JavaFXApplication1\nbproject\remote-platform-impl.xml:144: The following error occurred while executing this line:
C:\Users\manol\Documents\NetBeansProjects\JavaFXApplication1\nbproject\remote-platform-impl.xml:102: Remote command failed with exit status 1
BUILD FAILED (total time: 4 seconds)  

Command used in RaspberryPI

cd '/home/pi/NetBeansProjects//JavaFXApplication1'; '/usr/bin/java'  -Dfile.encoding=UTF-8   -jar /home/pi/NetBeansProjects//JavaFXApplication1/dist/JavaFXApplication1.jar

Error in RaspberryPI

Error: no se ha encontrado o cargado la clase principal javafxapplication1.JavaFXApplication1
Causado por: java.lang.NoClassDefFoundError: javafx/application/Application

Error creating JavaFX Project enter image description here
Error changing platform
enter image description here
enter image description here

  • Enable verbose output in NetBeans preferences, so you can see the stacktrace and find out about the error. – José Pereda Jan 30 '21 at 21:18
  • Thank you José, I don't know what exactly verbose Output means, but I've changed my verbosity level to "Verbose" In the Ant tools, and now I can see something in the "output- IDE Log" So I suppose that's what you mean. I've linked one image to the output on the question – manoleitor97 Jan 30 '21 at 22:19
  • What's your IDE version? Btw, it is better if you post the stacktrace with text instead of an image. The error happens after this [call](https://github.com/apache/netbeans/blob/6a9d4bdfa39bfdbbd1f60d22218818d3169348c5/java/java.j2seembedded/src/org/netbeans/modules/java/j2seembedded/project/RemoteBuildPropertiesProvider.java#L72), so you could try to find out running a small test locally with just a main class that prints out those system properties? – José Pereda Jan 31 '21 at 12:15
  • I have changed from 8.0 to 8.2, because I saw that was a bug in the 8.0 version. Now I get another error, and I'ts the same on the Netbeans 8.2 version and the Apache Netbeans 12.0. Anyway I don't know how to do the test you told me, sorry but I'm not used to this program, I guess you mean one "System.out.print" of what the error sends me to?. I'm gonna change the image to code and add the new error, but I don't know If I should do another question. Thanks again for your help – manoleitor97 Jan 31 '21 at 20:04
  • If you have deployed to your Pi the project via remote platform, even it if it fails, you can see the command that is used to run on your Pi. Go to the Pi, and run that command. Do you get the same error? Then see that the path to the JRE is correct and contains the JavaFX jars. – José Pereda Jan 31 '21 at 20:12
  • Okey, I did what you say, I edited the question so you can see what command I used (the one of the console says) and the error I'm getting. I searched for some information (https://stackoverflow.com/questions/34958550/dont-have-javafx-application-application-package-in-java) and It seems that I only need the file called "jfxrt.jar"? I have jdk 1.8.0_281 on my pc and I can't see it in the /jre/lib folder. I also downloaded last version (jdk15.0.2) and it doesn't even have a jre folder. – manoleitor97 Jan 31 '21 at 22:38
  • Have you seen this [answer](https://stackoverflow.com/questions/40481455/running-javafx-gui-on-the-raspberry-pi/40483500#40483500) on how to install JavaFX 8 for ARM? Note the procedure is different for Java 11/15... I take that you want to stick to 8? – José Pereda Jan 31 '21 at 23:03
  • Man, you are such a legend. I was missing the file called "javafx-mx".jar. And now It's all good and I can develop on remote. I only want Java 1.8 version because the newer ones dont have JavaFX as you said in the answer of the link you gave me. – manoleitor97 Feb 01 '21 at 16:07
  • Great that you solved it. Note that you can still run JavaFX 11/16-ea on Raspberry Pi with JDK 11+. You can find JDK distributions that bundle JavaFX for ARM, or you can find JavaFX for ARM [here](https://gluonhq.com/products/javafx/). – José Pereda Feb 01 '21 at 16:11
  • oooooh how I didn't know about this. So Can I have JavaFX 15.0.1(I prefer LTS over Early-Acces) With Java JDK 11.0.10 (again LTS) and remote working on the new Apache Netbeans 12.0? Damm I thought I had to use the older things but now I feel kinda stupid – manoleitor97 Feb 01 '21 at 16:24
  • Yes. As I mentioned before, you can find both JavaFX for ARM standalone or bundled with the JDK for ARM, for 11+. Then you can use NB 12, and remote platforms. – José Pereda Feb 01 '21 at 16:29
  • Okey, I have downloaded JDK 11.0.10 on the raspberry, and the JavaFX armv6hf SDK (11.0.2) on my pc. Now what I have to do is copy the files from the "lib" folder from the sdk to the "lib" folder on my jdk right? – manoleitor97 Feb 01 '21 at 16:59
  • No, you have to do the same as on desktop for JavaFX 11+, but with this SDK: Use `--module-path` referred to the path of your arm jars (i.e. `/opt/armv6hf/lib`) and `--add-modules javafx.controls, ...`. Alternatively, you can use Maven or Gradle, as well, with the JavaFX plugins, but with this SDK for ARM. – José Pereda Feb 01 '21 at 17:16
  • Okey, I actually didn't understand that at first, but with (https://openjfx.io/openjfx-docs/#install-javafx) I've finally Got JavaFX in the Raspberry and executed your HelloFX,but now I'm having problems again working with NetBeans on Remote. Because If I follow the guide and prepare JavaFX Non-modular from IDE, I can't make a new JavaFX project, I can only create a Java Application then change the code to a JavaFX because of the new libraries, and I can't change platform on a Java Application. I've linked an image of my error. Btw, I'm sorry If I'm being annoying, I just don't understand – manoleitor97 Feb 01 '21 at 18:37
  • You need to create a Java project (not JavaFX), and set the module-path/add-modules VM options for your Pi configuration (project properties->run, select Pi configuration, Pi runtime platform, and add VM options). – José Pereda Feb 01 '21 at 18:44
  • I am trying, but the program doesn't let me,I've added 2 more pictures. In one you can see that there is one Pi Platform, called "CasaPi" which is my RaspberrryPi3, but when I try to change the platform on the project properties (second photo) It only appears the Default platform – manoleitor97 Feb 01 '21 at 19:22

0 Answers0