When following the instructions trying to run the Test.sh file for the Java Library I get this output:
pi@raspberrypi:~/deviceWISE_University/GrovePi/Software/Java $ ./scripts/compile.sh && ./scripts/Test.sh
./src/com/dexterind/grovepi/Board.java:41: error: unreported exception UnsupportedBusNumberException; must be caught or declared to be thrown
final I2CBus bus = I2CFactory.getInstance(busId);
^
1 error
This is a fresh installation of both Raspbian and the GrovePi stuff.
Hey Josh,
I am not a Java expert but that does look like a problem with the I2C bus. Can you run i2cdetect -y 1 and post what you get there. You should see something with 04 in there. If not then there is a problem with the GrovePi. Did you try running another sensor with the python examples.
I have tried using a new installation of the Raspbian for Robots distro that Dex Ind has created. Even with the OS completely up to date I still get the same error when trying the Java compile and Test scripts.
Hey noname580, just want to hop in here. First, I just want to make sure you saw the directions for the GrovePi Java library here: https://github.com/DexterInd/GrovePi/tree/master/Software/Java
There are a few installation steps (getting pi4j) that need to be done before you get going.
We will try to coach you through this, but no one on staff are really Java experts, this was a community contributed library. We’ll do our best.
I’m having the same issue as Josh above. When I try and run the compile.sh it results in
./src/com/dexterind/grovepi/Board.java:41: error: unreported exception UnsupportedBusNumberException; must be caught or declared to be thrown
final I2CBus bus = I2CFactory.getInstance(busId);
And of course since the compile doesn’t work, the Test.sh fails also with a:
Error: Could not find or load main class Test
Is there a correction in the works, perhaps something allowing the usage of Java libraries through NetBeans?
I currently have a remote Netbeans connection to my Pi with PI4J and it works fine.
The addition of the Grove Pi+ adds a lot of possibilities but not so much if the Java libraries aren’t functioning.
Seems that I am still having issues with the Java library. Hopefully it is something simple I am missing. I am install pi4j and all pre-reqs.
Now I get the following output from the terminal when trying to execute either just the complie.sh or compile.sh and Test.sh together like the instructions.
pi@raspberrypi:~/Desktop/GrovePi/Software/Java $ sudo ./scripts/compile.sh && ./scripts/Test.sh
./src/com/dexterind/grovepi/Grovepi.java:40: error: unreported exception Exception; must be caught or declared to be thrown
instance = new Grovepi();
^
1 error
Thanks in advance again for any help with this. Thank you!
I have figured out what the problem is. There needs to be a try catch block when initiating the GrovePi instance in the ./Java/src/com/dexterind/grovepi/Grovepi.java file.
Change line 40 from
public static Grovepi getInstance() {
if(instance == null) {
instance = new Grovepi();
}
return instance;
}
To the following
public static Grovepi getInstance() {
if(instance == null) {
try {
instance = new Grovepi();
} catch (Exception e) {
System.out.println("There was an error");
}
}
return instance;
}
Now I am not a Java programer so there may be a much better way to write a try catch. Also I would have commented on git but not sure how to do that.
Added that bit of code the compile and Test both run without any apparent errors.