java

Clover web apps during runtime

Hello I am a Java web app developer I have a problem, I would like to make clover collect data during runtime for my web applications. I did manage to do so for a single application by adding a parameter to my tomcat (-Dclover.initstring.basedir="[PATH TO CLOVER DB]" ). It worked fine. But the problem is that we have more than one ap...

Flexible CountDownLatch?

I have encountered a problem twice now whereby a producer thread produces N work items, submits them to an ExecutorService and then needs to wait until all N items have been processed. Caveats N is not known in advance. If it were I would simply create a CountDownLatch and then have producer thread await() until all work was complete...

Difference between Apache Struts and Java EE?

I'm currently learning Java EE, or more specifically, Servlets and .jsp. In my programming, I already employ the Model-View-Controller model to write my code. And as far as I've googled, Apache Struts is just a server like Tomcat. So, what exactly is Apache Struts, in relation to Java, Java EE, and Servlet classes in Java EE? ...

Correctly synchronizing equals() in Java

I have the following class which contains only one field i. Access to this field is guarded by the lock of the object ("this"). When implementing equals() I need to lock this instance (a) and the other (b). If thread 1 calls a.equals(b) and at the same time thread 2 calls b.equals(a), the locking order is reverse in the two implementatio...

Will public access modifiers limits flexibility in changing code?If so give some examples..

Will public access modifiers limits flexibility in changing code?If so give some examples.. ...

Compare two java property files using shell script

How to compare two property files in two different folders using shell script input can be path of the two folders? There are multiple files in both folders and each files needs to be checked ...

Is it possible to programmatically close a Java process through JMX

Hi I'm currently writing an app to monitor another Java process and take specific actions when certain targets are hit. For example, if a thread deadlocks for a certain time, kill the thread, if the memory usage goes over a specific amount, send email alerts and kill the process, etc. My app will run as a stand-alone app, monitoring sp...

Un-killable java program

I have developed an application in java. I need that my java program would not terminated any process explorer/task manager. ...

[Android] Are static fields in Activity classes guaranteed to outlive a create/destroy cycle?

Hi, I frequently run into the problem that I have to preserve state between several invocations of an activity (i.e. going through several onCreate()/onDelete() cycles). Unfortunately, Android's support for doing that is really poor. As an easy way to preserve state, I thought that since the class is only loaded once by the class loade...

How to use ant to check for tags (TODO: etc) in java source

it's common to see something like this in code, hopefully only during development: //XXX: not in production! String password = "hello"; // getActualPassword(...); ... catch(Exception e) { /* TODO: Auto-generated catch block*/ } I would like ant to be able to a) warn (on TODO: / FIXME: tags) or fail (on XXX: or simmilar) The build serv...

Ensure that Spring Quartz job execution doesn't overlap

I have a Java program that executes from Spring Qquartz every 20 seconds. Sometimes it takes just few seconds to execute, but as data gets bigger I'm sure it run for 20 seconds or more. How can I prevent Quartz from firing/triggering the job while one instance is still being executed? Firing 2 jobs performing same operations on a databa...

Spring security 2.0.5. custom login form. Cannot see errors in language other than English.

Hello, I've got my Spring Security custom login form working. It displays errors if the user has input bad credentials, or is expired, etc. Looking inside spring-security-core-2.0.5.RELEASE.jar, I notice the following files in the org.springframework.security package: messages.properties messages_cs_CZ.properties messages_de.propertie...

OptimisticLocking and @OneToMany(mappedBy=...) handling?

I have an AbstractEntity class as superclass for all my entites that defines an optimistic lock column like this: @Version private long lockVersion; Now I often get OptimisticLockingExceptions on entities, that are only changed in one the mappedBy relations similar to the following: @OneToMany(mappedBy = Property.PROPERTY_DESCRIPTOR,...

How to render good quality image from 3d scene in java/c++

hello all i need to develop simple 3d application ( i don't know if its going to be java or c++ ) now how to use 3d engine i know , but in the end i need to produce rendered image or movie out of the 3d scene. who should i do it in application ? ...

Unable to handle multiple clients with threadpool as it is suspending the first thread as and when i got the second client request

hi to all i have created a server class with threadpool as shown below and it makes use of workerRunnable class . the problem i am facing with this code is when i am trying to send files from two cliensts at same time to this server,it is giving me a irregular response (in the sense first thread wil run till next client request is made ...

POI / Excel : applying formulas in a "relative" way

Hi, I'm using Apache's POI to manipulate Excel (.xls) files with Java. I'm trying to create a new cell whom content is the result of a formula as if the user had copied/pasted the formula (what i call the "relative" way, as opposite to "absolute"). To make myself clearer, here is a simple example : Cell A1 contains "1",B1 contains ...

DOMImplementationLS serialize to String in UTF-8 in Java

Hi, reading the documentation for java org.w3c.dom.ls it seems as a Element only can be serialized to a String with the java native string encoding, UTF-16. I need however to create a UTF-8 string, escaped or what not, I understand that it still will be a UTF-16 String. Anyone has an idea to get around this? I need the string to pass in ...

hibernate how to retrieve a hierarchy object

Hi all, I have the following beans Task, ServerDetails and ApplicationDetails. I wish to retrieve all tasks, their server details and application details based on a specific application name. From the result i expect to be able to retrieve the data in a manner such as: task.getServers().getApplicationDetails() In actuality, I get wha...

Can maven projects have multiple parents?

Hi, we have java and flex projects at work. We currently have 1 base pom that contains the configurations we want to use for both projects. Problem with this is: flex projects inherit configuration for javadoc and pmd for example, which they do not want. I want to do this a bit more clean and have a real base-pom and then a java-base-p...

Java: What is the fastest way to inject fields using reflection?

Hello, everyone! Suppose, I have a lot of classes, which are constructed using Java reflection (for some reason). Now I need to post-inject values to fields, which are annotated with @PostInject. public class SomeClass { @PostInject private final String someString = null; public void someMethod() { // here, someString has a...