Skip to content

Tag: java

How to upgrade JRE

Is there anyway to upgrade the installed JRE in the system? We are having 1.5.0_08 installed in out HP Unix system.We have to upgrade this to 1.5.0_15.Is there a way to patch up the existing JRE and upgrade to a newer version.Or can this only be achieved by installing the newer JRE and set this in the system …

Regular expression to match URLs in Java

I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java String flavor and pasted it into Java code, it does not work. The following class prints false: Does anyone know w…

Equivalent of PHP’s print_r in Java?

last time I asked how to populate a data structure here. Now I would like to know if there’s something in Java, like the print_r I use in PHP, to represent what I have populated in the Maps and lists without having to do my own algorithm. Any ideas? Answer Calling toString on the collection should retur…

Exception thrown inside catch block – will it be caught again?

This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below? I always thought the answer would be no, but…

How to pretty print XML from Java?

I have a Java String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nicely formatted XML. How do I do this? Note: My input is a String. My output is a String. (Basic) mock result: Answer Now it’s 2012 and Java can do more than it used to with