Recommended libraries/howtos for using WMI with java? [closed]

Hey Folks. I have a reasonably large commercial project (so for-pay licensing is always an option) that is moving into the windows space and I am planning on doing alot of polling with WMI. This is a Java 1.6 client app. Are there any good resources or books out there to get me started in accomplishing this in java? I feel my .NET fu is pretty strong, but I often don’t know where to start to accomplish the same tasks in Java.



I don’t know of any books specific to Java, but If I can offer some advice it would be to just start with WMI MSDN documentation. Also, since WMI is a COM based API, I would look into using a Java to COM bridge for accessing the API. Any one of the following should work:

For a Java wrapper around WMI, there is the jWMI library.


Compare 2 strings and display difference (php or javascript)

Comparing must work on-the-fly, so this must be done via javascript or with php (will make javascript ajax request).

What I need is probably advanced difference showing, so it will be probably best if there is any kind of good supported library.

This picture shows exactly what I need >

Tortoise Merge

Added #1:
I found this (example which is ok, but doesn’t support multiline? and it changes the whole word when only one character is different…

Added #2:
I tested php script ( ) but it has flaws.

Added #3:
I found what i was looking for ( )


This answer to a related question seems promising for javascript. google-diff-match-patch

It provides an API which will take care of all the complex and well known algorithms. However you’ll have to do some work with the presentation.

PHP is more versatile there is a lot of diff tools out there.
Look this other related question Calculate text diffs in PHP.


How a bookmarklet can avoid the popup blocker

I wrote a bookmarklet for quickly translating selected text using Google Translator in a popup window:

    var text = encodeURI(document.getSelection());
    if (!text.length) {
        text = prompt('Texto')
    var url = '' + text + ' &sl=es&tl=pt#';,'trans','left=20,top=20,width=1000,height=500,toolbar=0,location=0,resizable=1');

However, the Firefox popup blocker does not allow the new window to be opened. I can add exceptions for every site where I use the popup, but it can be pretty annoying…

I thought bookmarklets could open popup windows – actually, a lot of them do it, right? What am I doing wrong? Or is it not possible to do it?


There is another way of working around the popup blocker by first including a link overlaid on the page and then allowing the user to click that to generate the popup. The bookmarklet javascript can then be stored in a separate file. This is how Pinterest’s bookmarklet manages to do it. First they select images from the page and overlay it directly on the page. Then when the user clicks to select one of the photos the popup appears. Because this action was initiated by the user, the popup works.

Here’s some code you can use to test:

Place this in a file named bookmarklet.js

var popupProperties='width=600,height=400,toolbar=0,location=0,resizable=1';
var newA = document.createElement("a");
var url = '';
var newT = document.createTextNode("Open this");

And then your bookmarklet link can be like this:

javascript:var jsCode = document.createElement('script');jsCode.setAttribute('src', 'http://localhost/bookmarklet.js?r='+Math.random()*99999999);document.body.appendChild(jsCode);

Alternatively, you need to include the popup in the actual bookmarklet link. Which in turn will mean that the only way to make any changes is for the user to re-install the bookmarklet.

EDIT: In addition to the above method, I later found that there’s even another way to work around this by using easyXDM. It can help you work around the Same Origin Policy

Using this, you can use an iframe for your bookmarklet and you can even have a “close” link inside your iframe that will be able to remove the iframe from the parent page.


why hibernate changed HibernateException to (unchecked) RuntimeException

I know that in some version Hibernate exceptions were changed to be unchecked. what is the reason? is this a philosophy issue or practical one?


Practical. So you don’t have to wrap every one of your operations regarding Hibernate in try catch blocks.

Taken from Java Persistence with Hibernate:

A history of exceptions — Exceptions
and how they should be handled always
end in heated debates between Java
developers. It isn’t surprising that
Hibernate has some noteworthy history
as well. Until Hibernate 3.x, all
exceptions thrown by Hibernate were
checked exceptions, so every Hibernate
API forced the developer to catch and
handle exceptions. This strategy was
influenced by JDBC , which also throws
only checked exceptions. However, it
soon became clear that this doesn’t
make sense, because all exceptions
thrown by Hibernate are fatal. In many
cases, the best a developer can do in
this situation is to clean up, display
an error message, and exit the
application. Therefore, starting with
Hibernate 3.x, all exceptions thrown
by Hibernate are subtypes of the
unchecked Runtime Exception, which is
usually handled in a single location
in an application. This also makes any
Hibernate template or wrapper API


Sending an SMS in Android

Hey, I have been making an Android app which needs to send a text message. Here is the current code I have:

public class getMessage extends Service {
public IBinder onBind(Intent intent) {
    return null;

public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);

    client Phone = new client();

    String[] msg = Phone.getMsg(user[0],user[1]);
    PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, getMessage.class), 0);
    SmsManager man = SmsManager.getDefault();
    Log.e("GOT MESSAGE", msg[0]+ " : " +msg[1]);
    man.sendTextMessage(msg[0], null, msg[1], pi, null);
    Log.e("Message", "Sent the message?");

Now, for some reason, the text message will not send using this code, and I’m not sure why. I was hoping that someone here could help me out in finding why this message won’t send.

No error is raised, nothing appears in the log (except for the log messages that I make myself in the code). Also, the manifest does have the correct tags.



Well, now, this is embarrassing. Apparently, the way I was doing it WAS correct. Just the way that I was checking to see if it was sent was apparently incorrect.

When sending through code like this, it does not appear as a sent message on the phone, but will be received by the other person. I just had to test this by running two emulators.

Thanks for the help anyways, guys!

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..