java

How to detect deadlock ? Timeout in synchronized block?

I’m debugging a Java application that runs several threads. After a while of watching the log it seems that one of those threads is not running anymore. My guess is that the thread is waiting for a lock that is never released (the last output is before calling a synchronized method). Can I configure a timeout to the thread; a sort of “...

Appending to an ObjectOutputStream

Is it not possible to append to an ObjectOutputStream? I am trying to append to a list of objects. Following snippet is a function that is called whenever a job is finished. FileOutputStream fos = new FileOutputStream (preferences.getAppDataLocation() + "history" , true); ObjectOutputStream out = new ObjectOutputStream(fos);...

Continuous integration for Java with support for legacy project?

Hello everyone. I know that the Hudson vs. CC issue has been beaten (discussed) to death, but I would have a question from a different angle: which one of them (or maybe an entirely different CI product) is suitable for a legacy project? What I would specifically need is the possibility to filter out problems before a certain date. Som...

Real-time java sound volume adjustment

I play back sound with Java's SourceDataLine but whenever I try to adjust the volume (gain), there is a 0.2-0.5 second delay between the action and the response in the speaker. The audio data is written in 4k-16k chunks (16bit mono, 22kHz ~ 44k/s). How can I make this volume adjustment more real-time? Does the write(byte[], int, int) ...

Threadsafe java servlet

I need to know if there are any issues with the below code as far as threading goes. I was always under the impression that so long as class level variables are not used threading is not an issue. public class UploadReferralImage extends HttpServlet { String CLASS_NAME = "UploadReferralImage"; public void doGet(HttpServletRequest r...

DataSet class in Java?

Does anyone know if there is a DataSet class in Java like there is in .Net? I am familiar with EJB3 and the "java way" of doing data. However, I really still miss the seamless integration between database queries, xml and objects provided by the DataSet class. Has anyone found a Java implementation of DataSet (including DataTable, Dat...

Why do I get java.lang.AbstractMethodError when trying to load a blob in the db?

Hello, I've got a problem with JDBC. I'have the following code: //blargeparam is a blob column. PreparedStatement pst =connection.prepareStatement("update gcp_processparams_log set blargeparam= ? where idprocessparamslog=1"); pst.setBinaryStream(1,inputStream); I get the following error: Exception in thread "main" java.lang.Abstra...

How to fail a Maven build on a missing parameter?

I have a environment variable or jvm parameter which must be present. How do I get Maven to fail if this parameter does not exist? ...

How to determine Controller for given url (spring)

Using spring DefaultAnnotationHandlerMapping how can I lookup the Controller that would ultimately handle a given url. I currently have this, but feels like there ought to be a cleaner way than iterating over 100s of request mappings: public static Object getControllerForAction(String actionURL) { ApplicationContext context = getAp...

Why will socket connection to port 23 not work?

I have this small test socket connection class:- import java.net.Socket; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.IOException; public class TestTelnet { public static void main(String args[]) throws Exception { Telnet telnet = ...

Transparent Swing Windows

I have a little JWindow with a logo on it that users can drag stuff to. I develop my application mainly on OS X. To get a transparent window i use setBackground(new Color(0,0,0,0)); On a mac this works beautifully but i can't get the same effect on windows. Is there any way to get a transparent window without using 1.6 specific featur...

Is there a Java equivalent or methodology for the typedef keyword in C++?

Coming from a C and C++ background, I found judicious use of typedef to be incredibly helpful. Do you know of a way to achieve similar functionality in Java, whether that be a Java mechanism, pattern, or some other effective way you have used? Thanks, -bn ...

Hibernate custom type definitions

Hi Can someone please advise on how to define & map (using annotations) custom types in Hibernate? Eg, given: @Entity public class Line { private Point startPoint; private Point endPoint; } public class Point { private double x; private double y; } Rather than having Point persisted as an object, I'd like to see Lin...

Where is RequestMapping?

I downloaded spring-framework-2.5.6.SEC01-with-dependencies.zip. There is the RequestMapping javadoc in spring-framework-2.5.6.SEC01\docs\api\org\springframework\web\bind\annotation\ But in the spring-framework-2.5.6.SEC01\dist\spring.jar I can't find the RequestMapping class and the package org.springframework.web.bind. Am I download...

JPA Entity mapping with no foreign keys available

Hi, I dont really get to work with entity beans, but they are staring at me right now. We have a couple of tables that are related to each other, but there are no foreign keys, and we cannot add any. For this question, the database cannot change, it's just not possible, but as a different solution we might create views. Anyways... I...

How do I enforce assigning to arguments of methods using FindBugs?

As an alternative to littering my code with thousands of final keywords in front of my parameters, I'm trying to enforce it using FindBugs. It doesn't seem possible to do this, but there should be a way, shouldn't there? Thanks ...

Is there a Java tool to automate the reduction of class and method visibility?

I'm looking for a Java tool which can automate reducing the visibility of classes and methods which don't need to be public. I want to reduce the amount of methods/classes that are public so that the only remaining public ones are the ones I want to expose as part of the public API. I have quite a lot of classes and methods so would li...

Dynamically add rows to form with unique fields?

Hi Guys, I have a form that I am able to add new rows too for serial numbers for however many need to be entered but when i submit the form and it goes into my database it only submits the first 9 rows then loops back around and continues to submit the first 9 for however many rows have been added beyond that. Can anyone offer me assi...

How can I share memory between two JVM instances?

I build a huge graph in JVM (Scala) which I want to use repeatedly, tweaking algorithms. I'd rather not reload it each time from disk. Is there a way to have it sit in one JVM while connecting from another, where the algorithms are being developed? ...

Maven javadoc plugin - how can I include only certain classes?

Using the Maven javadoc plugin you can exclude certain packages - but I have lots of packages and only a handful of classes I want to produce Javadoc for. Is there a way to include rather than exclude? I would also like to do things on a class level rather than a package level as I have some classes in a package which need javadoc ...