在 Raspberry Pi 上运行 Javafx GUI [英] Running Javafx GUI on the Raspberry Pi

查看:30
本文介绍了在 Raspberry Pi 上运行 Javafx GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些程序需要在 Raspberry Pi 上运行,并在连接到 Raspberry Pi 的液晶显示器上显示输出.

我使用 Java 进行编程,使用 JavaFX 专门用于 GUI.但是在 Pi 上运行程序时,会出现不同的错误,有时无法检测到 javafx 扩展,有时无法找到主要类.

我用于 Pi 的操作系统是 Raspbian.并在 Putty 上执行所有通信.我曾尝试使用 jdk 1.8.0、1.7.0;ejdk;打开jdk.但似乎都给出了不同的错误.

如果有人能告诉我在 Pi 上安装相关 jdk 和 jre 的方法,如果我格式化我的 SD 卡并重新开始一切,那将非常有帮助.

此外,不使用 Javafx 的程序在 Pi 上运行时不会出现故障.

解决方案

如您所见

使用以下命令将允许您从命令行将文件移动到 JDK 所需的文件夹.您也可以为此使用图形工具.

cd 下载须藤 chown -R root:root armv6hf-sdkcd armv6hf-sdk须藤 mv lib/javafx-mx.jar/opt/jdk1.8.0_111/lib/光盘 rt/lib/须藤 mv j*/opt/jdk1.8.0_111/jre/lib/须藤 mv arm/*/opt/jdk1.8.0_111/jre/lib/arm/须藤 mv ext/*/opt/jdk1.8.0_111/jre/lib/ext/

之后您应该能够运行 Java/JavaFX 程序.

如果您还查看了 Gluon IDE 插件,您将能够在您的桌面上创建项目并在您的 Pi(以及您的桌面和移动设备)上远程部署它们.在此处查看文档以设置您的构建脚本.并在此处检查示例 GluonSQLite.

I have programs that I need to run on the Raspberry Pi and show the output on an lcd connected to the Raspberry Pi.

I have used Java for the programming and JavaFX specifically for the GUI. But on running the program on the Pi, it gives different errors, sometimes not detecting javafx extensions, sometimes not being able to find the main classes.

The OS I'm using for Pi is Raspbian. And performing all the communication on Putty. I have tried using jdk 1.8.0, 1.7.0; ejdk; openjdk. But all seem to give different errors.

It would be really helpful if someone could tell me a way to install the relevant jdk and jre on the Pi, if I format my SD Card and start over with everything.

Also, programs without the use of Javafx run without a glitch on the Pi.

解决方案

As you can read here, the most recent JDK versions for ARM don't include JavaFX.

If you want to use JavaFX in your Raspberry Pi, the solution is adding the missing JavaFX SDK.

If you install the recent Oracle's JDK for ARM from here (select jdk-8u111-linux-arm32-vfp-hflt.tar.gz), then you will need to download the JavaFX SDK from Gluon's site (select JavaFX Embedded SDK for armv6 hard float).

Once you have the file, unzip it, and copy the folders to your JDK.

Assuming you have downloaded armv6hf-sdk-8.60.8.zip to your Pi/Downloads folder, and you have unzip it to a folder armv6hf-sdk, like in the following picture:

using the following commands will allow you moving from command line the files to the JDK required folders. You can use a graphic tool for this as well.

cd Downloads
sudo chown -R root:root armv6hf-sdk
cd armv6hf-sdk
sudo mv lib/javafx-mx.jar /opt/jdk1.8.0_111/lib/
cd rt/lib/
sudo mv j* /opt/jdk1.8.0_111/jre/lib/
sudo mv arm/* /opt/jdk1.8.0_111/jre/lib/arm/
sudo mv ext/* /opt/jdk1.8.0_111/jre/lib/ext/ 

After that you should be able to run Java/JavaFX programs.

If you have a look also at the Gluon IDE plugins, you will be able to create projects on your desktop and deploy them remotely on your Pi (as well as on your desktop and mobile devices). Check the documentation here to set up your build script. And check the sample GluonSQLite here.

这篇关于在 Raspberry Pi 上运行 Javafx GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆