Importing classes & utilities in the manifest // JNA - classpath

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.*;

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.

Related

How to change the path of a jar file imported to a Netbeans project?

i imported a jfeonix jar file into my Netbeans project while it was in my pen drive. And it worked fine while the pen drive was still plugged on.
When i removed my pen, i cannot build my project and it says that
**Could not find resource file **
Then i tried copying the jar file to my desktop and then importing it again to the libraries of my project.. It would still give the same error, and the fact i fine surprising is that it still gives the same path as it was inside my pen drive even after i imported the jar file again from the Desktop..
So i was thinking what if i can changed the path to refer the jar file manually from inside the project...
has anyone faced this problem before?
Hope someone can help me with this..
Thanks in advance
i found the answer while doing a lot of things to my project..
apparently it seems that even if we delete the jar file from the library, it somehow is still there. and that's why it gives the same path even if we import the jar file again from a different place.
here's the answer i found, just in case someone faced this
Go to Project Properties in File Menu, there under Libraries u can see all the libraries that were imported..
like shown in the above picture, the other jar files i imported previously are noted as Broken reference.. So i just removed and it did the magic =D

Eclipse Scala IDE: can't open hierarchy for standard library classes

I have exactly the same problem as in this question: Eclipse: Using "Open Declaration" ... in a Scala project
However, I'm using the latest Scala IDE in version 3.0.2 (I have downloaded the Eclipse bundle from the site), and I would assume such basic functionality works by now, and apparently it's me who have something misconfigured.
I have created a new Scala project. Then I open some standard library class/trait/whatever, let's say scala.util.parsing.combinator.JavaTokenParsers. The source is neatly displayed, but when I try to show class hierarchy, I get the message: The resource is not on the build path of a Java project.
Also, searching for references etc. won't work.
I guess it is a matter of properly configuring the build path? Or maybe I should somehow attach Scala library sources to my project? But I can see the source, so aren't they attached already?
Here is the snapshot of my project configuration:
UPDATE:
By playing a bit with setting/resetting build path stuff, I managed to get rid of pop-up warning but the class hierarchy comes up empty and when searching for references I get only hits from my own sources, nothing from standard library.
In another workspace I also tried randomly adding and removing scala-library jars and got it work almost, but the type hierarchy comes up only with super-classes, without any sub-classes (which renders it quite useless). Searching for references works ok though.
Funny thing, I cannot make it work in my original workspace...
Gotta love Eclipse.
Your build path is not configured properly.
If you take a look under Scala Library[...] you have scala-library.jar we can only see one top-level package scala. There should be numerous other packages besides that. (Ruled Out)
I would recommend you follow these steps
Right-click project, build-path, Java-build-path, Libraries and make sure that the correct library is referenced there.
If it is the one you need, Try to remove this library and add it again, then clean and re-fresh the project. Also try this step in a fresh workspace.(something must have messed up this workspace )
Lastly. Goto the path D:\Eclipse For Scala\configuration\org.eclipse.osgi\bundles\286\1\.cp\lib and verify the sizes of the jars there. There should be 6 jars there and the size of scala-library jar should be around 6.8M. If size is smaller, consider re-downloading

Replace a gwt generated jar with a newer version

I've developed a GWT+GXT based web application. Recently we run into an issue that I was able to fix easily.
However when I generate the jar file from the tag, including the backport of the fix, even though I replace the old jar with the new one the fix has no effect.
On the other end if I generate the whole WAR everything works fine, but because of the size of it i'd rather like to be able to provide the patch as a jar file.
Am I missing something?
Thank you in advance
The jar file only contains Java sources and compiled Java - when you compile GWT, that produces JavaScript. This is what the war file contains, in addition to all of the other contents. In order to properly update your application, you need to update the compiled JavaScript.
The easiest way to do this, as you've noticed, is to replace the entire war file. If you want to keep the changes to a minimum, you could try just replacing the compiled JS directory and the jar file, but you'll want to be careful that you get the right directory - and all of the contents.

Set a classpath just for jUnit in Netbeans [duplicate]

We have an application developed in NetBeans, based on the NetBeans platform. There's a 3'rd party program that we have a runtime dependency on, more specifically a jar in the other progams lib folder.
How should we include the other progam's jar in our classpath?
The recommendation from the other progam's manufacturer is to set environment variable CLASSPATH to include
C:\Progam Files\Other Program\lib\theJAR.jar
And if that's not possible, we should copy theJAR.jar to JRE-HOME\lib\ext
We must not copy theJAR.jar anywhere else, that might cause it to stop working...
Now NetBeans takes no notice of what's on environment variable CLASSPATH. Their recommended way seems to be to make a wrapper, but that would lead to copying the jar, unless there's some way to make a wrapper module that points to CLASSPATH?
At the moment we are copying the jar into JRE-HOME\lib\ext. But then there's unnecessary hassle when we install some java update.
Do you have any solution to this problem? It seems like something that might be simple, but I haven't found the right place to look yet...
Edit: The application is ant-based.
From the documentation for the Module System API's overview of the runtime infrastructure (bottom of the page under the section "Common Problems and Solutions"):
Q: Can my module add a library JAR to the classpath from outside the
IDE [read: platform] installation?...
A: Not easily. You have a few options:
Add an entry to ide.cfg [your app's .config file]. For example:
-cp:a c:\eak\lib\eak.jar This startup file provides the ability to add classpath entries to the IDE's Java invocation.
...
It goes on to list two more options. The second option is the same solution you've come up with. The third is to "partition your module and use a new classloader" which I can't recommend either way since I have no experience doing this (but it's worth a read).
Assuming that this first option is what you are looking for, you will need to add a custom .conf file to your project and point to it in your project.properties file, like so: app.conf=nbproject/my.conf. This will add your custom .conf file to your app's install directory instead of the default config file that is normally added. Of course, you'll need to add the -cp:a c:\eak\lib\eak.jar entry to this custom config file in order to load the .jar.
During development you'll need to add the following entry to the project.properties file: run.args.extra=-cp:a c:\eak\lib\eak.jar. This will pass the command line option to your debug instance.
You can add that .jar file by following the steps below:
In the left side panel named "Projects" open your project and right click on the "Libraries", then select "Add JAR/Folder...".
Then select your .jar file from the location where you have stored it in the next dialog box that opens and then press "Open".
Vola Finished!!! (with the same process you can add other libraries also like JavaCV, JMF,etc)
And Now You Can Use That .Jar File From Your Project Library.
Hope It Helps.

How to set reference to the folder which contains multiple jar files?

My environment:
Netbean 6.9.1
Glassfish 3.0.1
Windows 7
Goal:
When my coworkers opens the Netbean Project, the library is already referenced without them manually create library, adding jars into it and reference it.
Detail:
I created Netbean project and the project has reference to few jar files in the folder.
Currently whoever opens the project for the first time, they have to manually create library and refer it to the project.
My project location:
C:\Users\masatosan\Desktop\myProject\myApp
My library location:
C:\Users\masatosan\Desktop\myProject\lib\myLib
The myLib folder contains:
some1.jar
some2.jar
some3.jar
I can achieve my goal if I create reference to individual jar file by defining to project.properties file like below: (creating reference to sqljdbc4.jar)
file.reference.sqljdbc4.jar=../lib/sqljdbc4.jar
javac.classpath=\
${libs.restlib_gfv3ee6.classpath}:\
${file.reference.sqljdbc4.jar}:
But my case is different since I have 3 jars in the myLib folder and wanting to reference them all.
Is it possible to reference all jars in myLib folder?
Please let me know if you need more clarification.
I'm sorry, but it doesn't work that way. When you create a project, you have to add the jar files individually.
However, if you put your lib folder under your project, netbeans will refer to them via relative paths. Then when you share the project (lib directory included), netbeans will be able to automatically find the jar files when the next person uses the project. That way you only have to add jar files once.
Short of using a dependency management tool like maven (which Netbeans has good support for), this is really the best solution. It uses a bit more disk space (obviously), but that's never been a huge issue for me.
I figured how so let me share.
Tool --> Library then library window pop up.
Create library called "MyLib" which contains multiple jars.
Add "MyLib" to your project. This change will be written to project.properties file under nbproject folder.
project.properties file indicates the classpath of lib reference you just added.
It should look like something below
javac.classpath=\
${libs.Excella.classpath}:\
${libs.MyLib.classpath}
Now someone else opens the project from different machine and she just needs to do step#1 and #2, which is to create library with same library name i.e. "MyLib"
I think this is what Bill was saying originally but thought it would be helpful to give step by step instructions since I finally figured .... after long time :D