GrovePi Java Problem

When following the instructions trying to run the file for the Java Library I get this output:

pi@raspberrypi:~/deviceWISE_University/GrovePi/Software/Java $ ./scripts/ && ./scripts/
./src/com/dexterind/grovepi/ 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.

Any questions please do not hesitate to ask.

Thanks in advance,


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.



Yes I do see a 04 when issuing the i2cdetect command.

pi@raspberrypi:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --    

The python programs for firmware check and led blink run fine.

I am using a Raspberry Pi V3 B if that makes any difference with the latest version of Jessie.

Thanks again,


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


Thank you John.

I did make sure that Pi4J was installed beforehand.

If I get a chance today I may dive into the Java library and see what I can come up with.

Also I would like to test it out on a RPi 2 to see if it is hardware or software.

Will keep this post updated with any findings.

I’m having the same issue as Josh above. When I try and run the it results in
./src/com/dexterind/grovepi/ 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 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.

Thanks for your help

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 or and together like the instructions.

pi@raspberrypi:~/Desktop/GrovePi/Software/Java $ sudo ./scripts/ && ./scripts/ 
./src/com/dexterind/grovepi/ 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/ 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.

Hi @noname580,

Both of your posts make sense and therefore I have created a Pull Request that treats this issue. Thanks for your contribution.

This the PR’s link:

If you like, you can also try the PR and see if it works correctly now.

Thank you!