There's a good discussion of Generics and what they really do behind the scenes over at http://stackoverflow.com/questions/31693/differences-in-generics so we all know that Vector < int[]> is a vector of integer arrays, and HashTable< String, Person> is a table of whose keys are strings and values Persons.
What stumps me is the usage ...
I've got a JSP page with a piece of Javascript validation code which limits to a certain amount of characters on submit. I'm using a <textarea> so I can't simply use a length attribute like in a <input type="text">.
I use document.getElementById("text").value.length to get the string length. I'm running Firefox 3.0 on Windows (but I've ...
Can anyone tell me the difference between break and continue statements?Thanks.
...
Is there any possibility of exceptions to occur other than RuntimeException in Java? Thanks.
...
I am querying data from views that are subject to change. I need to know if the column exists before I do a crs.get*X*().I have found that I can query the metadata like this to see if a column exist before I request the data from it.
ResultSetMetaData meta = crs.getMetaData();
int numCol = meta.getColumnCount();
for (int i = 1; i < nu...
I have some questions about logging, more specifically about setting it up and making sure it works.
The project I'm doing will use Wicket, Spring and Hibernate. I know that Wicket and Hibernate uses Simple Logging Facade for Java (SL4J) and that Spring is using the logging component from Apache Commons.
Will they co-exist happily?
I t...
I am aware of using jconsole to attach to a java process to get memory information. Specifically I'm after getting information on the various memory pools programatically so I can tie it to a monitoring application.
Thanks!
...
Follow up to: How to safely update a file that has many readers and one writer?
In my previous questions, I figured out that you can use FileChannel's lock to ensure an ordering on reads and writes.
But how do you handle the case if the writer fails mid-write (say the JVM crashes)? This basic algorithm would look like,
WRITER:
lock...
Let's say I have some Java code:
public class SomeClass {
static {
private final double PI = 3.14;
private final double SOME_CONSTANT = 5.76;
private final double SOME_OTHER_CONSTANT = 756.33;
}
//rest of class
}
If a thread is instantiating an instance of SomeClass and is in the middle of initializi...
I am trying to run WSDL2Java (Apache CXF) on a WSDL that contains overloaded methods (same method name, different parameters). It seems to me like I need to write either a JAX-WS mapping file or a JAXB mapping file to do this, but I feel like I'm being stonewalled by a ton of specifications I haven't read. Anyone have any examples of th...
I have two related clases JPA-annotated. Alarm and Status. One Alarm can have one Status.
What I need is to be able to delete one Status and "propagate" a null value to the Alarms that are in that Status that has been deleted.
That is, I need the foreign key to be defined as "on delete set null".
@Entity
public class Alarm {
@Id...
I intend to develop a small (Java) application for managing my finances. I believe I need to use an embedded database, but I have no experience regarding this issue. I tried to look at some of the available products, but I can't decide which one would be more suitable for me. H2, HSQLDB, Derby and Berkeley DB seem to be good candidates, ...
I have seen two ways of acquiring and disposing resources. Either:
Resource resource = getResource();
try { /* do something with resource */ }
finally { resource.close(); }
or:
Resource resource = null;
try { resource = getResource(); /* do something with resource */ }
finally { if (resource != null) resource.close(); }
I was wonde...
Please demonstrate how the ternary operator works with a regular if/else block. Example:
Boolean isValueBig = value > 100 ? true : false;
Exact Duplicate: How do I use the ternary operator?
...
I'm currently working on a project where I need to consume a Java webservice. If I connect to the service using old webservices (asmx) it works fine. However, If I try to do the same thing with a WCF client I get the following error:
The content type text/xml; charset=utf-8 of the response message does not match the content type of the...
I have a java application I need to pass some info to a C++ program. It has been suggested that I use some simple socket programming to do this. Is this the best way? If not what are the alternatives? If so, how should I go about learning about socket programming?
...
I challenge you :)
I have a process that someone already implemented. I will try to describe the requirements, and I was hoping I could get some input to the "best way" to do this.
It's for a financial institution.
I have a routing framework that will allow me to recieve files and send requests to other systems. I have a database I ...
I'm using Java - Ibatis and mySQL with Flex/Flash on the front-end. I have one requirement that is to be able to dynamically add creterias and table to a query depending on the user role. here is an example
Same object calling same SQL but different result based on role
Role 1 : Fully Access to employees
SELECT *
FROM Employee A
...
What exactly does JPA's fetch strategy control? I can't detect any difference between eager and lazy. In both cases JPA/Hibernate does not automatically join many-to-one relationships.
Example: Person has a single address. An address can belong to many people. The JPA annotated entity classes look like:
@Entity
public class Person {
...
I'm looking for a way to display a VNC viewer in a thick/rich java client (specifically, I'm using SWT, but if I can get it into AWT/Swing, I can integrate that specifically.) This is not an applet, but a real, live, thick java client.
TightVNC is probably sufficient; however, its GPL license is too restrictive for my needs.
Is anyone...