Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassNotFoundException: com.pi4j.library.pigpio.PiGpio #214

Closed
razorne opened this issue Apr 23, 2022 · 4 comments
Closed

java.lang.ClassNotFoundException: com.pi4j.library.pigpio.PiGpio #214

razorne opened this issue Apr 23, 2022 · 4 comments

Comments

@razorne
Copy link

razorne commented Apr 23, 2022

Hello,

i am new to the library and i am trying to make a led blink. I have written a short code, copying from the tutorial page on official website.

public static void main(String[] args) throws InterruptedException {
        int PIN_LED = 22;
        var pi4j = Pi4J.newAutoContext();
        var ledConfig = DigitalOutput.newConfigBuilder(pi4j)
                .id("led")
                .name("LED Flasher")
                .address(PIN_LED)
                .shutdown(DigitalState.LOW)
                .initial(DigitalState.LOW)
                .provider("pigpio-digital-output");

        var led = pi4j.create(ledConfig);

        led.low();
        Thread.sleep(1000);
        led.high();
        Thread.sleep(1000);
        pi4j.shutdown();
}

I am not using maven nor gradle to package the program (i am a maven user, but for this project, for reasons that are not relevant, i cannot use it) I run the program directly from the raspberry, using this sh:

java - cp "/home/rasp/project35/lib/*:/home/rasp/project35/dist/*" com.project35.Main

And this is the content of those folders. As you can see i am using the version of dependencies that are used in the official getting started page.

2022-04-23-133633_1920x1080_scrot

2022-04-23-133717_1920x1080_scrot

I am using JDK 11 since i have installed the Raspberry Pi OS Full (32-bit), just like suggested by the getting started page.

Am i missing something here?

Thanks

@savageautomate
Copy link
Member

I think you may be missing one or more transitive dependencies. The library JAR pi4j-library-pigpio-2..0.jar appears to be missing. Also you must have the PiGpio library installed on your Rpi. See: https://abyz.me.uk/rpi/pigpio/download.html

@razorne
Copy link
Author

razorne commented May 2, 2022

Thank for your comment. Yes i was missing that dependency, by adding it, and executing my sh as sudo (otherwise i would have received another error) i was able to make my led blink

@savageautomate
Copy link
Member

savageautomate commented May 4, 2022

Yes, sudo is required for using the PiGpio provider. I'm working on Linux GPIO (filesystem) providers now that don't require sudo access.

See: #212

@razorne
Copy link
Author

razorne commented May 5, 2022

Very nice! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants