Quiero desarrollar una aplicación de JavaFX en mi RaspberryPi, usando Netbeans como IDE para poder trabajar en remoto, esto es lo que he hecho:
1.instalado jdk 1.8 con sudo apt install openjdk-8-jdk
2.instalado la ultima versión de JavaFX Embedded SDK port, cambiando estos archivos:
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.instalado la libreria librxtx con sudo apt-get install librxtx-java
4.En netbeans, he usado como remote JRE path "/usr"
Output del IDE Log
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)
Aplicación
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);
}
}
Resultado
El resultado es que puedo desarrollar la aplicación, copiarla en la raspberry con ssh, y funciona perfectamente.Pero no puedo ejecutarla en remoto, cada vez que le doy a run no aparece nada en la consola y solo sale una notificación con el error "java.lang.NullPointerException"
Resultado en NetBeans 8.2 y 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)
Al no cargar la clase principal, pensé que podría ser un tema de permisos de archivo en la Raspberry, pero al parecer la carpeta NetBeansProyects tiene todos los permisos