Source: https://github.com/ttww/JavaFrameBuffer
The error:
pi@pi2 ~/jfb $ javah -d src/main/c -classpath bin org.tw.pi.framebuffer.FrameBuffer
Error: Could not find class file for ‘org.tw.pi.framebuffer.FrameBuffer’.
The fix:
#!/bin/sh jniResult=libFrameBufferJNI.so # Make sure to update these to your correct JDK path jniJdkHeader=/opt/jdk/current/include jniSysHeader=/opt/jdk/current/include/linux rm "$jniResult" echo "here is the correct compile command" javah -d src/main/c -classpath src/main/java org.tw.pi.framebuffer.FrameBuffer # rm src/main/c/org_tw_pi_framebuffer_FrameBuffer_ScreenPanel.h # rm src/main/c/org_tw_pi_framebuffer_FrameBuffer_UpdateThread.h echo "gcc" gcc -Wall -O2 -o "$jniResult" -shared -I "$jniJdkHeader" -I "$jniSysHeader" -I src/main/c src/main/c/FrameBuffer.c echo pwd ls -la "$jniResult" echo "done"
Compile the class, if you haven’t already:
javac -classpath src/main/java/ src/main/java/org/tw/pi/framebuffer/TestFrameBuffer.java
Execute the tester class:
LD_LIBRARY_PATH=. java -classpath src/main/java/ org.tw.pi.framebuffer.TestFrameBuffer
Example output:
Open with dummy_200x330 (10044216) width 200 height 330 bpp 0 Exception in thread "AWT-EventQueue-0" java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207) at java.awt.Window.<init>(Window.java:536) at java.awt.Frame.<init>(Frame.java:420) at javax.swing.JFrame.<init>(JFrame.java:225) at org.tw.pi.framebuffer.TestFrameBuffer$2.run(TestFrameBuffer.java:149) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744) at java.awt.EventQueue.access$400(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:697) at java.awt.EventQueue$3.run(EventQueue.java:691) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.awt.EventQueue.dispatchEvent(EventQueue.java:714) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
You need a window manager such as XMing:
Using XMing: