Raspberry pi flashing LED issue - Python vs Java

The GPIO_4 in the Python GPIO code corresponds to this diagram

enter image description here

The pi4j corresponds to the diagram below

enter image description here

So GPIO_04 is in a completely different location! You should change the java code to use GPIO_07

Here's an explanation of why wiringpi has different names for the pins. It's very confusing that they are both using GPIO_XX


I believe that your pin numbers might be off. Since the java code does not throw exceptions, I'd consider it likely that one of the pins is activated, but which has a different index than the one your LED is connected to.

The documentation of Pi4J lists this table for pin number reference: https://projects.drogon.net/raspberry-pi/wiringpi/pins/

Your python code uses the BCM index mode, whose port mappings are listed in the table. In this case, the BCM port 4 maps to GPIO_7 in Pi4j instead of the GPIO_4 you use in your java code.