-
Notifications
You must be signed in to change notification settings - Fork 446
Unhandled exception when running sample program SystemInfoExample #3
Comments
Additional info for my RPi: pi@mypi ~/workspace/SystemInfoExample $ hostname --all-fqdns pi@mypi ~/workspace/SystemInfoExample $ hostname -a pi@mypi ~/workspace/SystemInfoExample $ hostname -A pi@mypi ~/workspace/SystemInfoExample $ hostname -d |
same error "hostname --all-fqdns" returns nothing on my raspberry |
I will look into this issue next week. Thank you for the defect report. |
I've looked into this a bit more including studying the source code. I think the code is a bit eager to throw exceptions in places where it shouldn't. I see that you capture info in the form of key/value pairs, and if either a key or value is absent/invalid or blank, you throw an exception. In the context of program design, you require the caller to do some exception handling, and the implementation as it is now requires that the calling code is more complex than the called code. User code handling a possibly blank return value would have to add try/catch logic and translate an exception back to a blank value. This is a minor design problem. I would suggest that instead of throwing an exception for missing/invalid or blank key or value, that you instead return a blank string, which is actually closer to (or exactly) what the answer should be. |
The new 0.0.4-SNAPSHOT build is available for testing. This build includes changes to allow for empty/null NetworkInfo properties returned by the "hostname" command. You can download it from the Maven repository here: Please report success or any remaining open defects/issues. |
I am unfortunately running the Debian wheezy build (2012-08-08-wheezy-armel) which seems to have an older java than what you built for the 0.0.4 snapshot (the 0.0.3 jar file worked fine). I have attempted to bring it up to date with "sudo apt-get update" and "sudo apt-get upgrade" but the error remains. Without all the blah blah I get: root@mypi:/home/pi/workspace/SystemInfoExample# javac -cp pi4j-core-0.0.4-20121120.062224-1.jar -d . SystemInfoExample.java root@mypi:/home/pi/workspace/SystemInfoExample# sudo java -classpath .:pi4j-core-0.0.4-20121120.062224-1.jar com.pi4j.example.SystemInfoExampleHARDWARE INFOException in thread "main" java.lang.UnsupportedClassVersionError: com/pi4j/system/SystemInfo : Unsupported major.minor version 51.0 I visually inspected your code changes and the code base seems to be okay but I can't verify with what currently I have on my pi. [Sent from ice weasel on my pi. :-) ] |
On the Debian (armel) distribution, I am running the Oracle JDK 7u6 which is much faster than the OpenJDK. |
I have now updated to Oracle JDK 1.7.0_06 and the code works fine (fix verified). Thanks for all of your hard work! |
Thank you for testing it out. Issue closed. Fixed in 0.0.4-SNAPSHOT |
Make I2c polling on the MCP23017 IO expander dynamic
First, let me thank you for taking the time to do these excellent examples.
I get an exception on my Pi when running SystemInfoExample:
pi@mypi ~/workspace/SystemInfoExample $ sudo java -classpath .:pi4j-core-0.0.3-SNAPSHOT.jar com.pi4j.example.SystemInfoExample
HARDWARE INFO
Serial Number : 00000000xxxxxxxx
CPU Revision : 7
CPU Architecture : 7
CPU Part : 0xb76
MIPS : 697.95
Processor : ARMv6-compatible processor rev 7 (v6l)
Hardware Revision : 0005
Is Hard Float ABI : false
OPERATING SYSTEM INFO
OS Name : Linux
OS Version : 3.2.27+
OS Architecture : arm
JAVA ENVIRONMENT INFO
Java Vendor : Sun Microsystems Inc.
Java Vendor URL : http://java.sun.com/
Java Version : 1.6.0_24
Java VM : OpenJDK Zero VM
Java Runtime : OpenJDK Runtime Environment
NETWORK INFO
Hostname : mypi
IP Addresses : 192.168.20.140
Exception in thread "main" java.lang.RuntimeException: Invalid command: hostname --all-fqdns
at com.pi4j.system.NetworkInfo.executeCommand(NetworkInfo.java:82)
at com.pi4j.system.NetworkInfo.getFQDNs(NetworkInfo.java:103)
at com.pi4j.example.SystemInfoExample.main(SystemInfoExample.java:84)
pi@mypi ~/workspace/SystemInfoExample $
The text was updated successfully, but these errors were encountered: