Java Magazine, Sept/Oct 2016
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2016 31 internet of things 3 Name your platform whatever you like and set the following values as shown in Figure 3 a For Host specify your Raspberry Pis IP address b For Username specify the SSH user the default is pi c For Password specify the SSH password the default is raspberry d For Remote JRE Path specify the location of Java 8 Note Use sudo update alternatives display java to find the path 4 Click Finish Now you have a working JRE setup To enable this in your project open the Project Properties dialog box select the Run category and from the Runtime Platform list select the new platform you created You will be prompted to save the new configuration which you can name anything you like The final step is to modify the code to change the port name to match how the Nomad 883 Pro shows up under Raspbian Linux This port name will be available when you run the dmesg command after connecting the router via a USB For me the following value worked static String PORT_ NAME dev ttyACM0 Once this is all set up you can run debug and profile the sample code I provided on the Raspberry Pi right from your IDE The advantage of running the code on the Raspberry Pi is that you can execute the application without having a computer hooked up which frees your expensive laptop or desktop from issuing repetitive serial commands Also because the Raspberry Pi is a dedicated device the chance of timing delays or system crashes is greatly reduced For more information about running Java on the Raspberry Pi check out the book Raspberry Pi with Java Programming the Internet of Things IoT from Oracle Press A chapter from that book appeared in the May June 2015 issue of Java Magazine Ed Conclusion What this project shows is that a lot of the basic programming of devices consists of configuring the setup to receive commands from a Java program and then sending those commands to the device in a format it understands The Java tooling and its large ecosystem of software for devices makes this particularly easy article Stephen Chin is the lead Java community manager at Oracle Technology Network author of Raspberry Pi with Java coauthor of Pro JavaFX Platform and JavaOne community chair He is a fivetime Rock Star Award recipient Chin interviews hackers in their natural habitat and posts the videos on http nighthacking com Figure 3 The configuration screen in NetBeans
You must have JavaScript enabled to view digital editions.