Search code examples
classpathmanifestjna

Importing classes & utilities in the manifest // JNA


I'm a CS student and am in way over my head for an end of the year project, for which I need to find the dimensions and locations of a separate window. I've found that I need to use JNA libraries and understand how to do that but I don't understand how to import the JNA libraries through the manifest. Here is my file structure so far (I'm working in netbeans):

  • Project Folder
    • dist Folder
    • nbproject Folder
    • src Folder
    • Test Folder
    • Build.xml
    • Game.exe <-- This is the exe I run from the java file itself. I need to find this window's size and location for use later in the project
    • jna.jar <-- need to implement this as a classpath
    • Manifest.mf <-- I supposedly need to edit this.

The reason I show you this is to ensure that I've put the JNA Jar in the correct place.

Next, here is my manifest:

Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Class-Path: C:\Users\justi_000\Google Drive\4. APCS\JZMinesweeper\jna.jar

So I need to edit the bit after the java -cp but I don't know what to put there, and in what order. The java tuts, etc aren't of much help.

Additionally, are these imports correct? They may be the problem and I have correctly imported everything, but I doubt that.

import com.sun.jna.*;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.win32.*;

Solution

  • And, turns out, that it was a stupidly easy solution that my general incompetence caused me to miss.

    Turns out it is actually possible to directly import libraries in IDEs...probably why they all include a tool for it. Blind old me has only ever used them once before (the perils of being a student) but we're all set. Simple as right click libraries>add jar.

    Figured i would stick this here for future reference.