简体   繁体   English

在HTML中嵌入.jar(以RC Raspberry Pi的形式)

[英]embedding .jar in html (to RC a Raspberry Pi)

I'm working in a project; 我在一个项目中工作; we want to remote control a toy-car via 2 Raspberry Pi's (1 in the Car, 1 in the remote). 我们想通过2台Raspberry Pi遥控玩具车(在车上1个,在遥控器1个)。 It's all running so far, the remote can be used (touch display) to drive around with the car. 到目前为止,一切都已运行,可以使用遥控器(触摸屏)随车行驶。

We used Java so there is a .jar running on the remote Raspberry. 我们使用Java,因此在远程Raspberry上运行一个.jar。

We also want to implement a feature allowing remote control from the web. 我们还希望实现允许从Web进行远程控制的功能。

I know, after reading a bit, how to add a .jar in a website. 经过一番了解,我知道如何在网站中添加.jar。 But it will take a few days, till our web server is online and I could test it.. 但是要等几天,直到我们的Web服务器在线,我才能对其进行测试。

So I wanted to ask, will it be possible for the Java App, if running in a browser, to remotely control the car? 因此,我想问一下,如果Java App在浏览器中运行,是否可以远程控制汽车? I mean, the App is sending information (eg "Button left pressed") to a "Server" (which is our Router, both Raspberrys are connected to) 我的意思是,该应用程序正在将信息(例如“按下左键”)发送到“服务器”(这是我们的路由器,两个Raspberry均已连接到)

Or do I have to change things? 还是我必须改变事情?

A simple way could be to make a request to the server, like a REST Request. 一种简单的方法可以是向服务器发出请求,例如REST请求。 So that, every time you are calling the http://localhost/moveLeftButton where http://localhost is handled by your web server, an action is triggered. 这样,您呼叫的每一次http://localhost/moveLeftButton其中http://localhost是由Web服务器处理,被触发的动作。

It depends how you have implemented your server. 这取决于您如何实现服务器。 Try to have a look here: IBM Java and REST . 尝试在这里看看: IBM Java和REST

If you need some more complex communication (=stream), I can advice you javascript, streaming via web via websocket, using node.js and socket.io, you can find here some example with the rasp. 如果您需要一些更复杂的通信(= stream),我可以建议您使用javascript,使用node.js和socket.io通过websocket通过Web进行流传输, 在此处可以找到有关rasp的示例。

EDIT: using a .jar for a server and a .jar for an applet inside the browser sand box are two really different stories. 编辑:在服务器上使用.jar并在浏览器沙盒内为applet使用.jar是两个完全不同的故事。 I think it would be not so easy to let it work, and the java applet technology is pretty old. 我认为让它工作并不容易,而且Java applet技术已经很老了。 I advice you to do not try this, and just try to send messages from the browser to a server that is running on the raspberry. 我建议您不要尝试此操作,而只是尝试将消息从浏览器发送到在树莓派上运行的服务器。

No need to reinvent the wheel for this. 无需为此重新发明轮子。 Just bundle your .jar within a .war file and deploy it to java ee server that you would use to provide the HTTP/HTML interface. 只需将您的.jar捆绑在.war文件中,然后将其部署到Java ee服务器,即可使用该服务器提供HTTP / HTML接口。 For example, JBoss can be run just fine on Raspberry PI , and I've done it myself as well. 例如, JBoss可以在Raspberry PI上很好地运行 ,而我自己也已经做到了。

The interface could be for example REST interface mentioned, or any other HTTP based interface. 该接口可以是例如提到的REST接口或任何其他基于HTTP的接口。 HTML-based interface might be the easiest to work with, depending on your use case. 基于HTML的界面可能最容易使用,具体取决于您的用例。

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

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