java

How to change this regular expression to be case insenstive (looking for src tag)

Regualar expression: <img[^>]+src\s*=\s*['"]([^'"]+)['"][^>]*> This works fine when 'src' is in lowercase and manages both single and double quotes. I would like this expression to return matches for following test data 1. <html><img src ="kk.gif" alt="text"/></html> 2. <html><img Src ="kk.gif" alt="text"/></html> 3. <html><img sRC ="...

Killing thread instantly in Java

Is it possible to kill a Java thread without raising an exception in it? This is just for testing purposes - I want to simulate a case when the entire computer dies mid-thread. Note - I saw a deprecated Thread.destroy() method, but the documentation says it never got implemented in the first place. ...

Can I set the DPI resolution of my Java Swing application without changing the systems' DPI setting?

I have a Java application using the Substance LookAndFeel with Windows as the the target platform and I want to increase the DPI setting of my application without changing the system setting. I want to do this because I don't want to force the user to restart Windows and because many Windows applications seem to have problems with very ...

Struggling with generics and classes

I'm always struggling with generics. I don't know why this makes my go crazy. I have an old problem I've got several times. class Father { ... } class Child1 extends Father { ... } class Child2 extends Father { ... } public class TestClass { private static Class<? extends Father>[] myNiceClasses = new Class<? extends ...

Exception in J2EEC Phase while processing jax-ws-catalog.xml

Hi I should preface this with the fact that I am relatively new to EJB3 Metro and Java in general. I am writing an EJB3 application to run on glassfish v2.1 that needs to talk to a Microsoft CRM webservice within an NTLM authenticated network. I am using the JAX-WS (Metro) framework to access the webservice and want to use the XML cat...

Is it possible to use Jasper Reports to generate reports from LDAP

I'd like to be able to include the results of LDAP queries in Jasper reports. Is that feasible? From what I can gather it seems that the only way to go about this is to write my own custom datasource. ...

Programmatic deadlock detection in java

How can I programmatically detect that a deadlock has occurred in a Java program? ...

Augmenting instead of overriding Maven configuration.

I saw this question and it motivated me to look again (without success) at Maven configurations for an alternative way of declaring configuration so it is appended to the parent POM's config instead of overriding it. In a Maven POM, if configuration declares the same elements as in the parent it overrides the parents configuration. As th...

How to browse local Java App Engine datastore?

It seems there is no equivalent of Python App Engine's _ah/admin for the Java implementation of Google App Engine. Is there a manual way I can browse the datastore? Where are the files to be found on my machine? (I am using the App Engine plugin with Eclipse on OS X). ...

JVM errors after updating to Java 6 Update 14

I've been getting some strange errors ( perhaps once per day ) after updating a handful of servers to run on Java 6 update 14. The errors are similar to # # A fatal error has been detected by the Java Runtime Environment: # # java.lang.OutOfMemoryError: requested 1759920 bytes for Chunk::new. Out of swap space? # # Internal Error (al...

what is the difference between cfproperty tag defined variable and the variables scope variable in coldfusion?

What is the difference between cfproperty tag defined variable and the variables scope variable in ColdFusion? I have Java language experience, can you compare the ColdFusion cfproperty variable, variables scope variable to the Java instance variable and class variable? greate thanks! ...

OSGI Declarative Services (DS): What is a good way of using service component instances

I am just getting started with OSGI and Declarative Services (DS) using Equinox and Eclipse PDE. I have 2 Bundles, A and B. Bundle A exposes a component which is consumed by Bundle B. Both bundles also expose this service to the OSGI Service registry again. Everything works fine so far and Equinox is wireing the components together, ...

Apache POI HWPF, replacing text in .doc documents fails

I try to write down the result of the POI unit test at: code here, by adding the line daDoc.write(new FileOutputStream("C:\\wordtest.doc")); to the end of the method testRangeReplacementAll. The new document is corrupt when I try to open it with word 2003. Any suggestions to fix this? ...

Retrieve Windows Live Contacts using Java

I am trying to build a proof of concept for a project, in which i have to display the user contacts once he sign in to live account. I have gone through the corresponding SDK. But the problem is, i don't have any ONLINE domain to test it. I am building a POC and whatever i want to do is to do on localhost. using the sample code provided...

How to check a String is a numeric type in java

How would you check if a string was a number before parsing it? ...

CustomException checked or unchecked

If I declare class Class MyOwnException extends Exception { } Is this is a checked or unchecked exception? ...

How would you encode a Map<String, Object> using Protocol Buffers?

I'm trying to use Protocol Buffers for message serialization. My message format should contain Map< String, Object > entries ... but how do I write the .proto definition? As far as I know, Protocol Buffers does not have a build-in Map type. I could model around that using repeating fields. But the big problem I have is, that you need ...

How does Java's Hello World work without an object instance?

Hi, I'm a newbie to Java and I'm confused about something: In the simple hello world program in Java, no object is created so how does the class work in the following example? public class HelloWorld { public static void main (String args[]) { System.out.println ("Hello World!"); } } ...

Generate low-order non-printable characters from XLST

I'm trying to use XSLT text output to generate a file (in a file format that I'm not in control of), and while it is mostly text, it includes low-order non-printable characters as flags, including characters that are not valid within an XLST file (according to the XSLT specification). I'd like for something like the below to work, but i...

Compile and interpret JSP with Java only

I would like to compile and interpret JSP in Java, out of Tomcat or any other servlet container. I think I may use the Jasper libraries coming with Tomcat, but I can't find any example of how to do it on the Web. The minimum I need is a function that returns an String (HTML resulting text) from a compiled JSP and a HttpServletRequest, ...