Timothy Wall

Greenhorn
+ Follow
since Sep 14, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Timothy Wall

The sunos variants haven't yet been updated due to lack of hardware. Feel free to do a build and submit it to the JNA user's list.
14 years ago
Use char[] or byte[] for character buffers, not StringBuilder. Follow the recommended type mappings given in http://jna.dev.java.net and the JNA JavaDoc overview.
14 years ago
If it's a COM DLL, then either JACOB or JAWIN will let you access the DLL without any JNI programming.

If it's a straight C API exported by the DLL, then JNA should do the trick (again, without any JNI programming).
14 years ago
JACOB and JAWIN allow you to access the functions of a DLL if it exports a COM interface. JNA provides access to the DLLs functions if it exports C-callable functions. None of these options requires any JNI programming.

Presumably your DLL has some other documentation that tells you what API it provides.
[ September 07, 2007: Message edited by: Timothy Wall ]
14 years ago

Originally posted by Jesus Angeles:
My front end needs to be done using java swing/awt. I am however, required, to reuse existing perl codes. Is JNI able to talk to Perl directly? Or JNI to c, then c will talk to perl (if that is possible).



JNA will allow you to call directly into a DLL which exports a C-callable interface, so you could conceivably call into the perl interpreter.

Alternatively you could invoke a perl process via Runtime.exec and collect the results via the filesystem.
14 years ago

Originally posted by Yohan Liyanage:
Hello,

Is there any way in Java to access system information like Processor Use (Load) without loosing the platform independance? I have heard that there is a possibility through JNI. But use of JNI will make the application to be platform specific, isn't it?



JNA makes it easy to obtain this sort of information directly from the host OS without using JNI, but you have to provide an implementation for each OS that has a different API. Josh Marinacci did an implementation for OSX so he could have a java-based CPU monitor.
14 years ago

Originally posted by Ulf Dittmer:
It's hard to say what's going on without seeing the code, but you either need to make sure that the file is not overwritten by the JNI code (maybe by waiting until the applet has finished painting it; it could signal that it's done by deleting the file), or by using different file names (e.g. file_0001.txt, file_0002.txt). Then the reading/painting code just needs a bit of logic to select the file with the lowest number.



I'd recommend you don't do anything but paint an image in paintComponent. The file read and image generation should be done on a thread other than the event dispatch thread. When you've finished generating the image, then you can pass it to your component and call repaint(). Otherwise, your UI will stutter and jerk according to your system's disk activity.
14 years ago

Originally posted by George Lin:

I think I should attach to javaw.exe, right?



One instance of javaw.exe will be the eclipse process. Depending on your launch settings, your program might be run as javaw.exe OR java.exe. If you look in windows task manager, the process with the smaller memory footprint is likely yours (eclipse runs around 200Mb).
14 years ago

Originally posted by vijay kumar:
Hi,
i want to call a DLL from my java code and need to pass some parameter to it.

can any one help me how to comunicate with DLL through java.



JAWIN and JACOB provide good access to COM-based DLLs. JNA provides easy access to DLLs which export a standard C interface.
14 years ago

Originally posted by Justin Fox:
i know that you can capture mouse events inside the JFrame, but what if i wanted to keep track of everytime a mouse button was clicked, even outside the JFrame. Is there a way to accomplish this in java? or do i need to look into another programming language?

Justin



JNA (http://jna.dev.java.net) might make things easier; I wrote a utility using it to detect which keys are currently pressed that works on w32 and X11 systems. You still have to dig into native OS APIs, but it's much easier than JNI.
14 years ago
You can always create the applet yourself and set its AppletContext to a small stub implementation, then call the init() and start() methods. You can also call JApplet.getContentPane() and reinstall that component in a JFrame's content pane, assuming the applet doesn't assume too much about its environment.
15 years ago
The JNA project includes some demo code which uses the w32 file system API to report file system changes. You don't have to write any native code, but you may need to tweak the java if the class doesn't do exactly what you want it to already.
15 years ago

Originally posted by Muhammad Ali Amin:
Hi,

I want to call a generic dll from JAVA. The dll is provided by thirdparty. I am able to load it using "System.load("dllName.dll");" but i am now confused how can i call the methods. Since it is not made by me using JNI so there is not method with "native" keyword.

Is there any way to use its method?



There are a few Java libraries that will let you do this:
JNA (http://jna.dev.java.net)
JNative (http://jnative.sf.net)
NLINK (http://nlink.dev.java.net)
15 years ago
Depending on your needs, there are several GUI testing frameworks available in addition to JFCUnit.
Jemmy (http://jemmy.netbeans.org) is a netbeans-oriented framework, very similar to JFCUnit, and is sponsored by Sun.
Neither jemmy nor jfcunit supports scripting, and all tests are hand-coded. The primary method of event generation is hand-stuffing the AWT event queue, although I believe both projects have recently added Robot support.
Abbot (short for "A Better 'Bot", at http://abbot.sourceforge.net) and Pounder (http://pounder.sourceforge.net) provide record and playback. Pounder records low-level events for playback, with some protection against component size changes.
Abbot records low-level events and parses them in to high-level user semantic events as much as possible. Abbot also provides a loose coupling for component references, so that in most cases, moving a component around in the hierarchy won't affect script playback. Abbot may also be used directly in java code for GUI unit tests similar to JFCUnit.