別の StackOverflow 投稿のサンプル コード - Java - How to take a screenshot fastを使用していますが、いくつか問題があります。
Github リポジトリから JNA ファイルをダウンロードし、JAR ファイル内のファイルをコピーして、プログラムと同じフォルダーに配置しました。しかし、プログラムをコンパイルしようとすると、以下に示すように多くのエラーが発生します。
C:\Users\windows\Desktop\testPrintScreen>javac JNAScreenShot.java
JNAScreenShot.java:12: error: package com.sun.jna.platform.win32 does not exist
import com.sun.jna.platform.win32.W32API;
^
JNAScreenShot.java:129: error: package com.sun.jna.platform.win32 does not exist
interface GDI32 extends com.sun.jna.platform.win32.GDI32 {
^
JNAScreenShot.java:58: error: cannot find symbol
bufferedImageFromBitmap(GDI32.HDC blitDC,
^
symbol: class HDC
location: interface GDI32
JNAScreenShot.java:59: error: cannot find symbol
GDI32.HBITMAP outputBitmap,
^
symbol: class HBITMAP
location: interface GDI32
JNAScreenShot.java:60: error: cannot find symbol
GDI32.BITMAPINFO bi) {
^
symbol: class BITMAPINFO
location: interface GDI32
JNAScreenShot.java:151: error: package com.sun.jna.platform.win32 does not exist
interface User32 extends com.sun.jna.platform.win32.User32 {
誰が何が起こっているのか知っていますか?問題を引き起こしているのはインポート部分ですか?これらは私の輸入品です:
import com.sun.jna.Native;
import com.sun.jna.platform.win32.W32API;
import com.sun.jna.win32.W32APIOptions;