java

UnexpectedRollbackException - a full scenario analysis

All I know about this exception is from Spring's documentation and some forum posts with frostrated developers pasting huge stack traces, and no replies. From Spring's documentation: Thrown when an attempt to commit a transaction resulted in an unexpected rollback I want to understand once and for all Exactly what causes it? ...

Serialize objects containing objects java

I try to serialize an object that contains an other object which is itself serializable. Is there a way to make it work ? The pointer to the other object seems to be lost when I serialize the first object. ...

maven jetty plugin - how to control vm arguments?

How to set vmargs for jetty runned from maven-jetty-plugin? I need for example to pass -Xmx argument to Jetty which run as maven-plugin (maven-jetty-plugin) by "mvn jetty:run" command. ...

Hudson style build reports on developer machines/within Eclipse

We use Hudson for our continuous integration which provides us with easy to browse build reports showing compiler warnings, unit test results and coverage (EMMA), pmd, checkstyle and findbugs violations. Although we each have the relevant plugins installed locally in Eclipse, it often seems easier to simply commit to SVN in order to tri...

Get output from a process

Hi, This is a second part to my question here. I now have a process but I want to know how to get the output from the process? String filename = matlab.getfileName(); Process p = Runtime.getRuntime().exec("java -cp mediaProperty.java " + filename); My mediaProperty.java: public class mediaProperty { public static Object m...

Degree of relation between Java object and classes/interfaces?

Is there some way through the standard library or some already existing library to determine the degree of relation between two classes/interfaces in Java? Let's say I have an object and a list of classes/interfaces. Now I basically want to know the one class of that list, that has the shortest inheritance-tree path to this object. I ...

How to scan a file in a different directory in java?

How do you scan a file with java that isn't in the directory the java file is in? For example: The java file is located at "C:\Files\JavaFiles\test.java" However, the file I want to scan is located at "C:\Data\DataPacket99\data.txt" Note: I've already tried putting another java file in the "C:\Data" directory and using the test.java fi...

java timers: how to select + what are the limitations?

I need to write some code to stress-test RS232 communication using rxtx (note: this question is NOT about serial communications, so please don't go there), and I would like to periodically send bytes using some kind of timer task. Are there any kind of guidelines online about what kind of timer class to use for various applications? I'm...

In what order do static initializer blocks in Java run?

Say a project contains several classes, each of which has a static initializer block. In what order do those blocks run? I know that within a class, such blocks are run in the order they appear in the code. I've read that it's the same across classes, but some sample code I wrote disagrees with that. I used this code: package pkg; ...

What is the most widely used feed-parsing library for Android

I want to make an app which (amongst other things) can parse feeds loaded via the network. Given that the standard Anrdoid + Core Java libraries do not provide a feed parser service and I dont want to write a one myself, can you nominate a Java feed parser which will work on a low-spec Android device. I'm just starting out learning And...

Catch invalid hibernate connection URL error

If I put the wrong connection URL in my hibernate.cfg.xml file, I want to be able to detect it and terminate gracefully, but I can't figure out how; it just hangs indefinitely on buildSessionFactory() during the hibernate initialisation procedure: SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); It'...

java ui implementation: short-term test + progress indicator w/o using separate dialog

I need to add a simple GUI for running a stress-test. I would like to do something like this: State 0: stress-test is not in progress -- in this state the user can enter/increment a number in a spinner. Pressing the go button will start the test and transition to state 1. [spinner] [go button] State 1: stress-test is in progress -- i...

Want to convert process into a multi-threaded process

Let me go over what my code is doing (haven't coded it yet), I want to make it run in multiple threads to speed things up. looks for a record in the database that hasn't been processed yet: SELECT TOP 1 * FROM Products WHERE isActive = 1 looks up a URL (Rest call), returns back the HTML and stores it in the database Sets the flag for...

Java daemon design practices

I'm writing a daemon in Java that takes in requests from multiple providers in which the provider would return a service object for the daemon to run as a thread. Application architecture: Main class Providers Services Libraries / Models List item Main class Basically loads the configuration file, initializes libraries required, etc...

Constant Parameter Design

I am working with a Class that contains constants or parameter values that all classes can reference for example; public class Parameters { public static final String JUMP_TO_VALUE = "Parameters.JUMP_TO_VALUE"; public static final String EXCEPTION_ID = "Parameters.EXCEPTION_ID"; } Some of the foundation classes in my applicati...

java function - print(collection c) ?

Hi. I'm trying to learn java better and I got one question. Say I got two collections, an ArrayList and a LinkedHashSet. Is it possible to make a function like this: void print(collection c) { for (object tmp:c) { System.out.println(tmp); } } ...

How to delete cookies?

I want to delete cookies programmatically. More specifically, I am using HtmlUnit with Java to automate browser operations. After performing some operations I want to clear cookies so that my subsequent operations make sense. How can I clear cookies through HtmlUnit or through Java or through any other way automatically. ...

Xstream: removing class attribute

How do I remove the class=”Something ” attributes in Xstream . I use Xstream with annotations ...

Unchecked exceptions in Java: Inherit from Error or RuntimeException?

I would like to handle errors with (unchecked) exceptions. I heared that for each kind of exception I should create a subclass of either Error or RuntimeException. What's the difference? ...

Is there something like LINQ for Java?

Started to learn LINQ with C#. Especially LINQ to Objects and LINQ to XML. I really enjoy the power of LINQ. I learned that there is something called JLINQ a Jscript implementation. Also (as Catbert posted) Scala will have LINQ Do you know if LINQ or something similar will be a part of Java 7? Update: Interesting post from 2008 - http...