Skip to content

Tag: java

JDI Thread Evaluations has encountered a problem

I’m running Eclipse for Java. I created a DOM version of an XML file. Now I want to change an attribute of an element in the file. I called a method that called a method in the class that controls the DOM, and I got a dialog box saying “JDI Thread Evaluations has encountered a problem. Exception p…

Convert Month String to Integer in Java

Given a month string such as: Is there any core Java or third party library functionality that would allow you to convert this string to the corresponding month number in a locale agnostic way? Answer An alternative to SimpleDateFormat using Joda time:

Run a java function after a specific number of seconds

I have a specific function that I want to be executed after 5 seconds. How can I do that in Java? I found javax.swing.timer, but I can’t really understand how to use it. It looks like I’m looking for something way simpler then this class provides. Please add a simple usage example. Answer EDIT: ja…

How to detect the current display with Java?

I have 2 displays connected, so I can either launch my Java application on the primary or the secondary display. The question is: How can I know which display contains my app window, i.e., is there a way to detect the current display with Java? Answer java.awt.Window is the base class of all top level windows…

Add HEADER in HTTP Request in Java

I’m using this following code to send simple HTTP Request : However, as you can see, I don’t send a custom HEADER. What should I add to send a custom HEADER ? Answer When you write The rnrn bit is sending a line-feed/carriage-return to end the line and then another one to indicate that there are n…

Delete SMS in Android 1.5

There are many questions about it, no answers are working in my application 🙁 I need to remove SMS from a receiver, even if the user can see it, but it must be removed programmatically. How can I do it? The most suitable I have used was the following, but it doesn’t work 🙁 Answer After refactoring my co…