简体   繁体   English

有关Raspberry PI的任何Java经验吗?

[英]Any Java experience on Raspberry PI?

Is it possible to run average java app server on eg jboss or glassfish server on Raspberry pi? 是否可以在Raspberry pi上的例如jboss或glassfish服务器上运行普通的Java应用服务器? Any limitations? 任何限制? Does anyone have an experience in Java development for raspberry pi? 有没有人有覆盆子pi的Java开发经验?

At least any appropriate JVM for RPi will be nice. 至少任何适用于RPi的JVM都会很好。

It's absolutely possible, but should work better with newer versions having more memory (eg the 512 MB version of the Pi). 这绝对是可能的,但是对于具有更多内存的新版本(例如,512 MB版本的Pi),应该可以更好地工作。 In December 2012 Oracle released a Developer Preview of Java SE 8 for ARM . 2012年12月,Oracle发布了面向ARM的Java SE 8开发人员预览版 The blog post with the announcement contains links to a number of tutorials which should get you started with plain Java SE or JavaFX, depending on how fancy your interfaces should be. 该公告的博客文章包含许多教程的链接,这些教程应该让您从简单的Java SE或JavaFX开始,具体取决于您的界面应该是多么花哨。

  1. Quickie Guide Getting Java Embedded Running on Raspberry Pi Quickie Guide在Raspberry Pi上运行Java Embedded
  2. JavaFX on Raspberry Pi – 3 Easy Steps Raspberry Pi上的JavaFX - 3个简单步骤

If you are concerned about the performance of JavaFX on the Raspberry Pi, check the blog post "JavaFX on Raspberry PI" , which contains some information about the performance of JavaFX, comparing it to native applications. 如果您担心Raspberry Pi上JavaFX的性能,请查看博客文章“Raspberry PI上的JavaFX” ,其中包含有关JavaFX性能的一些信息,并将其与本机应用程序进行比较。

Update: Test results after running Tomcat 7 with Java 8 on the Pi 更新:在Pi上运行带有Java 8的Tomcat 7之后的测试结果
After I got the 512mb version of the Pi (MODELL B), I installed Java 8 and Tomcat 7.0 without any problems. 在我获得了512mb版本的Pi(MODELL B)之后,我安装了Java 8和Tomcat 7.0而没有任何问题。 Tomcat examples were working, and I was able to use the Tomcat manager application without any problems. Tomcat示例正在运行,我能够毫无问题地使用Tomcat管理器应用程序。

With 64 MB of RAM used for the graphics card, I still had 291 MB of free memory (with sshd running): 使用64 MB RAM用于显卡,我仍然有291 MB的可用内存(运行sshd):

pi@raspberrypi ~/ $ free -m
             total       used       free     shared    buffers     cached
Mem:           438        146        291          0         10         74
-/+ buffers/cache:         60        377
Swap:           99          0         99

pmap reported a total of 192 MB being used by the Tomcat process. pmap报告了Tomcat进程总共使用了192 MB。

Raspberry Pi has only 185MB available for the whole JVM. Raspberry Pi只有185MB可用于整个JVM。 (after boot, with 16MB to video processing). (启动后,16MB进行视频处理)。

Then, you need to use aggresive and precise memory options ( -Xmx120M -XX:MaxPermSize=55M -XX:ReservedCodeCacheSize=4M -Djava.awt.headless=true ) 然后,您需要使用积极和精确的内存选项( -Xmx120M -XX:MaxPermSize=55M -XX:ReservedCodeCacheSize=4M -Djava.awt.headless=true

I have made an application based on Jetty, Spring 3 and Hibernate/JPA. 我已经基于Jetty,Spring 3和Hibernate / JPA创建了一个应用程序。 Just after deployment, it fit in about 15MB of Heap space and 32MB of non heap space (using JProfiler memory analysis) 在部署之后,它适合大约15MB的堆空间和32MB的非堆空间(使用JProfiler内存分析)

Each loaded class is permanent memory lost, because PermGen space can't be garbage collected. 每个加载的类都会永久丢失内存,因为PermGen空间不能被垃圾回收。 A lot of classes are loaded only for initialization support, but will stay loaded forever. 许多类只加载初始化支持,但会永远保持加载状态。 Maybe tweeks can be found to consume less PermGen space for each component. 也许可以发现tweeks为每个组件消耗更少的PermGen空间。

You can indeed. 你的确可以。 There is a blog post of someone running JBoss EAP (essentially JBoss AS 7) on a raspberry pi. 一篇关于在树莓派上运行JBoss EAP(基本上是JBoss AS 7)的博客文章

我在JRE 1.7下的Raspberry Pi上使用TJWS,它的工作速度非常快,没有内存问题。

Right now, a JVM on the pi is possible but a Java SE edition is hard to find. 现在,pi上的JVM是可能的,但很难找到Java SE版本。 There may be one for ARM from Oracle, but I haven't tried it (my pi is still on it's way) and if memory serves it's behind a wall. 可能有一个来自Oracle的ARM,但我还没有尝试过(我的pi仍在使用它)并且如果内存服务它就在墙后面。

Another limitation for the pi is the available RAM; pi的另一个限制是可用的RAM; apps like jboss and glassfish are going to want more RAM than the pi provides, except under very constrained deployments. 像jboss和glassfish这样的应用程序将需要比pi提供的更多RAM,除非在非常有限的部署中。

Ive got tomcat7 running on openjdk with sqlite databases. 我已经使用sqlite数据库在openjdk上运行tomcat7。 Processing ok at around a quater speed of my laptop, but opening jsp pages takes 10-15 seconds. 在我的笔记本电脑的四分之一速度处理正常,但打开jsp页面需要10-15秒。 Not sure why yet. 不知道为什么。

in case you want to use java 11 and javafx I found this is definitely possible with the Liberica JDK of BellSoft: https://bell-sw.com/pages/java-11.0.3 如果您想使用java 11和javafx,我发现使用BellSoft的Liberica JDK肯定是可行的: https ://bell-sw.com/pages/java-11.0.3

Install scripts and demo application are available on my blog: https://webtechie.be/2019/04/16/pijava-overview-java-11-and-javafx-11-on-raspberry-pi 我的博客上提供了安装脚本和演示应用程序: https//webtechie.be/2019/04/16/pijava-overview-java-11-and-javafx-11-on-raspberry-pi

To install JDK 11.0.2: 要安装JDK 11.0.2:

# Make sure we are in the home directory
cd /home/pi

# Download the Java 11.0.2 distribution from BellSoft
wget https://download.bell-sw.com/java/11.0.2/bellsoft-jdk11.0.2-linux-arm32-vfp-hflt.tar.gz

# Move the downloaded file to /opt
sudo mv bellsoft-jdk11.0.2-linux-arm32-vfp-hflt.tar.gz /opt

# Use the /opt directory
cd /opt

# Untar the downloaded file
sudo tar -xvzf bellsoft-jdk11.0.2-linux-arm32-vfp-hflt.tar.gz

# Remove the downloaded file
sudo rm bellsoft-jdk11.0.2-linux-arm32-vfp-hflt.tar.gz

Testing and running Java file without compiling: 在不编译的情况下测试和运行Java文件:

cd /home/pi
nano HelloWorld.java

public class HelloWorld {
    public static void main (String[] args) {
        System.out.println("Hello World");
    }
}

/opt/jdk-11/bin/java /home/pi/HelloWorld.java
Hello World

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM