Code Monkey home page Code Monkey logo

Comments (9)

HBrydon avatar HBrydon commented on July 19, 2024

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
pi@mypi ~/workspace/SystemInfoExample $ hostname -f
mypi
pi@mypi ~/workspace/SystemInfoExample $ hostname -i
127.0.1.1
pi@mypi ~/workspace/SystemInfoExample $ hostname -I
192.168.20.140
pi@mypi ~/workspace/SystemInfoExample $ hostname -s
mypi
pi@mypi ~/workspace/SystemInfoExample $ hostname -y
hostname: Local domain name not set
pi@mypi ~/workspace/SystemInfoExample $

from pi4j-v1.

fizou avatar fizou commented on July 19, 2024

same error "hostname --all-fqdns" returns nothing on my raspberry

from pi4j-v1.

savageautomate avatar savageautomate commented on July 19, 2024

I will look into this issue next week. Thank you for the defect report.

from pi4j-v1.

HBrydon avatar HBrydon commented on July 19, 2024

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.

from pi4j-v1.

savageautomate avatar savageautomate commented on July 19, 2024

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:
https://oss.sonatype.org/content/groups/public/com/pi4j/pi4j-core/0.0.4-SNAPSHOT/

Please report success or any remaining open defects/issues.

from pi4j-v1.

HBrydon avatar HBrydon commented on July 19, 2024

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
warning: pi4j-core-0.0.4-20121120.062224-1.jar(com/pi4j/system/NetworkInfo.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: pi4j-core-0.0.4-20121120.062224-1.jar(com/pi4j/system/SystemInfo.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
2 warnings
root@mypi:/home/pi/workspace/SystemInfoExample#
root@mypi:/home/pi/workspace/SystemInfoExample#

root@mypi:/home/pi/workspace/SystemInfoExample# sudo java -classpath .:pi4j-core-0.0.4-20121120.062224-1.jar com.pi4j.example.SystemInfoExample

HARDWARE INFO

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/pi4j/system/SystemInfo : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at com.pi4j.example.SystemInfoExample.main(SystemInfoExample.java:51)
root@mypi:/home/pi/workspace/SystemInfoExample#

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. :-) ]

from pi4j-v1.

savageautomate avatar savageautomate commented on July 19, 2024

On the Debian (armel) distribution, I am running the Oracle JDK 7u6 which is much faster than the OpenJDK.
http://www.savagehomeautomation.com/projects/raspberry-pi-installing-oracle-java-development-kit-jdk-170u.html

from pi4j-v1.

HBrydon avatar HBrydon commented on July 19, 2024

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!

from pi4j-v1.

savageautomate avatar savageautomate commented on July 19, 2024

Thank you for testing it out. Issue closed. Fixed in 0.0.4-SNAPSHOT

from pi4j-v1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.