I can compile this JNA example code (from step 2 of https://github.com/twall/jna/#getting_started):
package com.sun.jna.examples;
import com.sun.jna.Library
In Eclipse, under Java Build path > Order and export
, select export jna.jar
.
Either just remove this line and recompile (which is fine in this case as you just try out some sample)
package com.sun.jna.examples;
or read up on what packages in java are and how they have to be handled (ChssPly76s Posts as a starter).
Better choose the second option as sooner or later (probably sooner) you will have to deal with packages anyway. So just take the time now to read up on it.
This example (as well as vast majority of java classes) uses packages:
package com.sun.jna.examples;
In order to compile / run it properly you need to run javac / java from the "root" folder (e.g. folder where "com" is located):
Let's say you have a folder called examples
. You'd put both the jna.jar
and the source code in it preserving folder structure:
/examples
jna.jar
/com
/sun
/jna
/examples
HelloWorld.java
You compile and run using:
javac -classpath .:jna.jar -g com/sun/jna/examples/HelloWorld.java
java -classpath .:jna.jar com.sun.jna.examples.HelloWorld
Note the path separators in the former case and dots in the latter.