from time to time I am haunted by the "org.eclipse.swt.SWTError: No more handles". I already know tools like GDIView, to watch the number of handles allocated, but now I wonder if there is a better way to do this.
Is there a tool available? Maybe one that logs all stacktraces when handles are created? And which shows the new handles between two invocation points?
Regards,
Daniel
PS: Added the windows tag because dev occures mostly on windows and a windows only tool would be good enough.
I found out about Sleak, a great tool to debug SWT resources! Highly recommended for everyone with the same problems. Even shows the images for image resources!
For me the issue was simply that new Shell() has been called too often. Storing the shell as static member and reusing it helped. Therefore, before applying a tool like Sleak, others might want to do a full text search for "new Shell" and check that they don't have the same simple cause.
Related
Possible silly question alert.
Being a bit of a hoarder, when I noticed that you can check all available sources after downloading Eclipse and then download and install all of those plugins I was ecstatic! I don't have to do that all manually! Yet I've tried it twice and each time I try to install all of them I can't boot Eclipse back up (it just hangs on the splash screen with no loading messages). I've tried deleting my .metadata folder and running it via ./eclipse -clean but both haven't helped. Is it just not possible to run with every single plugin installed?
Thanks!
"Hoarding" can turn into a very bad habit.
Maybe this is your chance to learn to you should try to resist the impulse "add more, please".
Keep in mind that Eclipse is a TOOL to help you creating better software. It can't help you when you blow it up to a degree that it is just busy with managing all the things you added.
I would even suggest to act in an opposite way: ONLY use the plugins and features that help you to get your job done. But for those plugins - learn to USE all the functionality that they offer to you. So, if you want please the "inner hoarder" in you: tell him to hoard knowledge; not things. "Things" consume space, and finally "energy" - there are good reasons that the Chinese art of "Feng Shui" asks people to keep LESS items around.
I am creating a complex game, because of this I use System.out.println(); a lot to test to see if something works or to see if something went wrong. To see these messages I have been going to the CMD or terminal and running it from there but I was wondering if there was an easier way. I thought of a couple ways and came up with running with a batch, but I have no idea how to make one, and another way was to put a button in game that opens the console that the game is running in. I don't even know if the second one is possible but I was wondering if there was a way! Thanks in advanced!
This is what logging frameworks are for.
Use sfl4j - http://www.slf4j.org/ - in your code to generate the log events, and choose a suitable backend for your purpose. I would suggest using slf4j-simple which is easy to get started with and which easily can be sent to a file you can view in your favorite file viewer.
http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
I'm looking to write a Linux/Windows/Mac Java HID controller for a simple wireless HID interface device. I've tinkered around with the USB4Java LibUsb library to no avail, and I've been steered in the direction of the JavaHIDAPI.
Unfortunately for me, I really have no idea what I'm doing beyond a pretty decent higher level programming skill set (C#/VB.Net), and switching over to this is killing me.
The directions that I found said that I would first need to compile the HIDAPI library found here. It said it would build something called hidapi-jni.dll (which it didn't).
Anyway, I think this is where I need to go since the HID does nothing but simply sends and receives signals to and from a wireless control (and responds to signals received).
Is there any step-by-step tutorial for using the JavaHIDAPI for this? Or is there a better library? (I noticed that this is a bit... dated).
I tried myself with the following:
static{ System.loadLibrary("hidapi"); }
.
.
.
public static void main(string[] Args) throws . . . {
ClassPathLibraryLoader.loadNativeHIDLibrary();
HIDDevice dev = HIDManager.getInstance().openById(VEND_ID, PROD_ID, null);
.
.
.
}
The issue into which I am running is that (besides the fact that the HIDAPI doesnt seem to be building into HIDAPI-jni.dll) is that the HIDManager.openById(. . .) always returns null. Also, I moved the hidapi.dll that was built into the C:...\Java...\bin directory... or something, I'm sure it's right because there wasn't any unsatisfied link error. It's really frustrating because there doesn't seem to be any newbies guide to Java and HID anywhere.
What am I doing wrong here?
I'm a bit late to answer this question, but I've written a library called hid4java that might solve your problem.
It's based on Java Native Access (JNA) which is a lot simpler than faffing about with complex JNI incantations.
I had to write it because javahidapi is out of date and the underlying signal11/hidapi code has moved on considerably. The older versions of the hidapi library had problems on OS X with attach/detach events which have now been fixed so an upgrade is necessary.
Also I found it impossible to claim a USB HID device through usb4java on OS X so I ended up writing this library to solve that problem.
Hope it helps.
So the issue, I discovered, was with native libraries.
I was able to get the application to work by copying the .dll from the .jar file and referencing it, but more important, I'm going to rebuild the .java class file responsible for loading the library and add the
System.loadLibrary();
call. When the JavaHidApi ClassPathLibraryLoader.loadNativeHIDLibrary(); method is called it doesn't load the library upon successfully writing it out to the temp file which is mildly annoying. Doing this will eliminate the necessity for manually loading the library from a static location...
Thank you for pointing me in the correct direction.
I have no Java experience and prefer Visual Basic; I've found a very nice translation IDE called Basic4android (www.basic4android.com). It works by interpreting a scripting language that's similar to Visual Basic and then using it to generate and compile native Java code. Rather ingenious, if you ask me. In fact I believe I found it from a reference here on StackOverflow.
I'm having some trouble wrapping PayPal's Mobile Payments Library:
www.x.com/community/ppx/xspaces/mobile/mep (scroll down for the HTML Tutorial)
I need to do it in a way that promotes the library's functionality so that B4A can in turn expose it to the Android device (emulator in this case). I've made some halting progress so far, but now I'm stuck on NullPointerExceptions occurring deep within the MPL.
The saga is pretty well described in a thread at their forum:
http://www.basic4ppc.com/forum/additional-libraries-official-updates/8819-looking-download-link.html
Here's my wrapper and the generated code—download here—as only licensed users may access downloads in that particular forum section.
The latest NullPointerException occurs a few calls down from the initWithAppID function. The JD-GUI decompiler reports an internal error when it gets to the com.paypal.android.b.b class, so it doesn't appear to be possible to know exactly what's going on down there.
I'm certain this can be done; I just need to know how to open the proper communication channel between the device and the MPL.
I'm new at Java and I'm new at Android. Quite a combination, wouldn't you say?
It turns out the problem is in the way PayPal bundles their resource files; non-Eclipse projects can't get at them.
More info on the original B4A thread.
Thanks,
Jeff
I think if you ask here about something that generates code for you, you won't be provided with any answers because you can't give any useful source code or something. Also, if you use something like this tool, you never know what it's generating. Also, you can't fix any occurring errors with the generated code... I could go on and on and on...
If you want to use Android the way it's supposed to be used, you'll need to learn Java and Android. If you are good with VB, this shouldn't be that hard. And this is what anyone is going to tell you.
I am trying to make a contribution to the windows task bar so when i minimize my app it docks itself into the windows task bar , the best way of describing this is by looking at a picture I have drawn:
If anybody knows if this is possible or how to do it please let me know.
I am well aware of the ability to add an icon to the system tray - but this is slightly different.
Thanks in advance,
Andy
You should probably have to use JNI or JNA to achieve this - wrapping the native windows API seems like the most viable idea. It'll greatly diminish the value of using Java, however - using JNI/JNA should always be considered last resort...
Take a look at SWT. This will definitely be a platform specific solution but I am assuming this isn't an issue for you.
SWT (Beginning with 3.6 which just went gold) has a TaskBar class and corresponding TaskItem classes for each item in the TaskBar. I don't think the TaskItem class is going to be powerful enough to do what you are asking for, but by looking at the source it will provide you insight into the low level Windows calls that you can access to get this done.
The SWT version for Windows will have a low level platform specific API that should get you where you want to go. Basically they have done all the JNA/JNI work for you. I am not a Windows programmer so I can't give you more details, but hopefully this will point you in the right direction.
You just need to use the System Tray functionality available in Java 6.
If you look at the More Information section at the bottom of that page it has links to the System Tray API and an example project.
Could you hide your application on minimize and then add an icon for it to the system tray that, when clicked, unhides your application?