开发者

Can Java applets use API's for hardware?

I've been tasked with creating software that needs to work on Macs and PCs.

开发者_如何学GoThe software needs to talk to some USB hardware that does bits and bobs.

To prevent having to maintain two pieces of software, I thought about the possibility of writing a Java applet, I'm pretty new to Java but am OK at C# and C, and did do a bit of Java at university so I should be ok with it, but my question is, can a Java applet communicate with an API for some USB hardware, or is this not possible due to security reasons?


Yes you can by using native library via JNI. This is platform-dependent so you would have to write code that abstracts this away. Also applet would need to be signed.

http://www.javaworld.com/javaworld/jw-10-1998/jw-10-apptowin32.html


I would also look at using webstart rather than an applet. It's a lot more flexible and just works better. This explains the security features and signed jar files:

http://download.oracle.com/javase/tutorial/deployment/webstart/security.html

I should add this only applies if you're starting the application from a remote web site. If you just want to run a java program locally, then you don't have to worry about all this.


I think security is going to cut you off. Does your software HAVE to be browser based? A lot of people associate "Applet" with Java naturally, but you CAN just make a full-blown application in Java as well. That would have access to the local hardware.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜