java

Checked Unchecked Exceptions

Consider the following code private int meth() { try { return 1; } catch(Exception ex) { return 2; } finally { return 3; } } When the aforeseen code is compiled, "Exception" is treated as unchecked exception. That is "unreachable catch block Exception is never thrown in try block" compil...

How to avoid OOM (Out of memory) error when retrieving all records from huge table?

Hi all, I am given a task to convert a huge table to custom XML file. I will be using Java for this job. If I simply issue a "SELECT * FROM customer", it may return huge amount of data that eventually causing OOM. I wonder, is there a way i can process the record immediately once it become available, and remove the record from memory a...

JProgressBar

any methods available to stop a JProgressBar at runtime?? i wil start a progress bar wen a button is clicked(which wil start a thread at the back ground). what i exactly want is to stop the progress bar wen a deadlock situation occurs in my program.. This is the gist of my program.. ...

How to check a string starts with numeric number?

Hi all, I have a string which contains alphanumeric character. I need to check whether the string is started with number. Thanks, ...

Is GIJ (GNU Interpreter for Java) stable enough for commercial use?

Hi, I have been asked to write a java program on linux platform. According to system admin, the JRE on the linux system is GIJ, which is supposed to be compatible to JRE 1.4.2. java version "1.4.2" gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-44) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see ...

Using Java 5 enums as Velocity variables

hi, all. I need to use java 5 enum in velocity template, so that I could write something like public enum Level{ INFO, ERROR; } Velocity template: #if($var == Level.INFO) ... #else ... #end How can it be done? Thanks in advance. ...

How can I filter rows in a JTable?

i have a JTable having many strings in that.i have created a textbox for user entry, above the table. i want a row filter which can remove the rows having strings enterd by the user in the text box. please help me out for this. ...

Java's answer to PHP's SoapClient() ?

There's a lot of information out there, but I can't quite figure out: What's Java's answer to PHP's SoapClient()? No frills, just want to create a client to access the methods described by a .wsdl document. ...

what could be the reason for my java UI unit test grabbing focus on GNOME desktop

I am running a UI unit test with multiple scenarios that requires the UI to get focus when it starts. This test runs for a while and I am facing an issue in GNOME desktop where the focus goes back to this application for each scenario it executes; this prevents me from using my machine when this test case running. This works fine on win...

Java String Special character replacement

Hi all, I have string which contains alpahanumeric and special character. I need to replace each and every special char with some string. For eg, Input string = "ja*va st&ri%n@&" Expected o/p = "jaasteriskvaspacestandripercentagenatand" = "asterisk" & = "and" % = "percentage" @ = "at" thanks, ...

Why does Java have such a large footprint?

Java - or at least Sun's Hotspot JVM - has long had a reputation for having a very large memory footprint. What exactly is it about the JVM that gives it this reputation? I'd be interested in a detailed breakdown: how much memory goes to the runtime (the JIT? the GC/memory management? the classloader?) anything related to "auxiliary" A...

VCDIFF for Java or alternative binary diff formats

Is there an open-source Java implementation of the VCDIFF binary diff format (decoder and encoder)? There are xdelta and open-vcdiff, but those are both C libraries. Alternatively, are the other formats/algorithms that one could use to generate diffs for binary files from Java? ...

Junit4 : expected=Exception not working with SPRING

I'm trying to use the @Test(expected = RuntimeException.class) annotation in order to test for an expected exception. My code is as follows: @Test(expected = RuntimeException.class) public void testSaveThrowsRuntimeException(){ User user = domain.save(null); } and my save method simple like this : publ...

What to do, if debug behaviour differs from normal execution?

I have a problem with debugging sessions. My program executes very well in a debug session but if I start a normal run, it behaves completely different. The problem is, that I cannot say, why it acts different. One possible reason is the slower execution time because you alway have to press F6 or so. I tried to insert Thread.sleep(1000)...

what is swingset2

I looked at some demos but did not find any atricles that explain the concept. Demo link ...

Benchmarking Performance on Java VM vs .Net CLR

Have you ever had to justify the choice over using .Net instead of Java based on performance? For a typical high volume transaction processing system that can perform the following operations, Concurrent Database transactions Mathematical computations Interaction with other web services (SOAP/XML, XML-RPC) My approach would be to co...

Stored procedure for everything

I had a heated discussion with a colleague on the usage of stored procedures (SP) in a .NET application (on an SQL server 2005 database). [He has a Microsoft background and I Java - which may or may not be relevant]. I have to insert data captured in the UI. For this I would write a SP and use that in the .NET code? It's not required b...

Howto load a resource from WEB-INF directory of a web archive

I have a web archive with a file placed in the WEB-INF directory. How do I load that file in a java class? I know I can put it in the classes directory and load it from there. It would just be put it in WEB-INF. ...

Problem with ModelAndView and ModelMap in AnnotationController, Springframework

I have a question that is a point difference between ModelAndView and ModelMap. I want to maintain modelAndView when requestMethod is "GET" and requestMethod is "POST". My modelAndView saved others. So I made modelAndView return type to "GET", "POST" methods. But, Request lost commandObject, form:errors..., if request return showForm ...

Implementation for custom keys in Hashtable

If we implement our own keys in Hashtable, then our custom hashtable keys must implement public int hashCode() { } and public Object equals(Object obj) { } What will be the implementations for these methods? ...