Skip to main content Accessibility help
×
Hostname: page-component-78c5997874-8bhkd Total loading time: 0 Render date: 2024-11-09T23:02:30.810Z Has data issue: false hasContentIssue false

23 - Accessing the platform

Published online by Cambridge University Press:  08 January 2010

Clark S. Lindsey
Affiliation:
Space-H Services, Maryland
Johnny S. Tolliver
Affiliation:
Oak Ridge National Laboratory, Tennessee
Thomas Lindblad
Affiliation:
Royal Institute of Technology, Stockholm
Get access

Summary

Escaping the sandbox

The Java Virtual Machine (JVM) is often said to provide a safe and self-contained sandbox where programs such as applets can play without accidentally or deliberately entering restricted areas of the platform. That is sufficient if all a program does is interact with the user via a graphical interface but many programs need to reach out and access the world beyond the JVM to obtain information and interact with external hardware.

In Chapter 22 we showed how Java classes can link to native codes, which possess none of Java's security restrictions. This is the ultimate form of local platform access but it involves a lot of inelegant coding and violates the portability of Java. In this chapter we look at less drastic ways that a program can access the platform. We first show how a program can obtain properties describing the platform such as the operating system, the Java version, and screen size. We then explain how to run a non-Java program from within a Java program. Next we discuss how to use serial ports to communicate with external devices. We include a demonstration program in which a Java application communicates via a serial port with a temperature sensor.

We note that the security restrictions put into place by a browser JVM place severe limits on the access that applets have to the platform and the network. However, as we saw in Chapter 14, the security restrictions on Java applications can be easily customized as needed.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Glen McCluskey, Using Runtime.exec to Invoke Child Processes, Core Java Technologies Tech Tips, March 4, 2003, http://java.sun.com/developer/JDCTechTips/2003/tt0304.html
javax.comm for Windows and Solaris platforms, http://java.sun.com/products/javacomm/
javax.comm for Linux, www.rxtx.org
jUSB – open source USB support for Linux, http://jusb.sourceforge.net
Elliotte Rusty Harold, Java I/O, O'Reilly, 1999
Ian F. Darwin, Java Cookbook, 2nd edition, O'Reilly, 2004
Christopher E. Strangio, The RS-232 Standard: A Tutorial with Signal Names and Definitions, CAMI Research, 2004, www.camiresearch.com/Data_Com_Basics/RS232_standard.html
Craig Peacock, Interfacing the Serial and RS-232 Port, 2001, www.beyondlogic.org/serial/serial.htm
SerialPort – Commercial software from www.serialio.com
Al Williams, Embedded Internet Design, McGraw-Hill, 2003

Save book to Kindle

To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×