java

No Such Method Error when creating JUnit test

I've tried figuring out this problem for the last 2 days with no luck. I'm simply trying to create an annotation based JUnit test using the spring framework along with hibernate. My IDE is netbeans 6.5 and I'm using hibernate 3, spring 2.5.5 and JUnit 4.4. Here's the error I'm getting: Testcase: testFindContacts(com.mycontacts.data.d...

How to wire Interdependent beans in Spring?

I want to declare two beans and instantiate them using Spring dependency injection? <bean id="sessionFactory" class="SessionFactoryImpl"> <property name="entityInterceptor" ref="entityInterceptor"/> </bean> <bean id="entityInterceptor" class="EntityInterceptorImpl"> <property name="sessionFactory" ref="sessionFactory"/> </bean> But...

Java Style: Properly handling exceptions.

I keep getting stuck conceptually on deciding an Exception-handling structure for my project. Suppose you have, as an example: public abstract class Data { public abstract String read(); } And two subclasses FileData, which reads your data from some specified file, and StaticData, which just returns some pre-defined constant data....

When learning Java, how important is it to know Unix well?

Hi, Other than the Java language itself, you have to learn the java framework. Similiar to how you have to learn the .net framework in addition to the language (C#/VB). How important is it to know unix? Or rather, what unix areas should one focus on? Seeing as many people run java based applications (desktop/web) on unix boxes, what...

How to check if array element is null to avoid NullPointerException in Java

I have a partially nfilled array of objects, and when I iterate through them I tried to check to see whether the selected object is null before I do other stuff with it. However, even the act of checking if it is null seem to through a NullPointerException. array.length will include all null elements as well. How do you go about checking...

How do I paint Swing Components to a PDF file with iText?

I would like to print my Swing JComponent via iText to pdf. JComponent com = new JPanel(); com.add( new JLabel("hello") ); PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream( dFile ) ); document.open( ); PdfContentByte cb = writer.getDirectContent( ); PdfTemplate tp = cb.createTemplate( pageImageableWidth, pageI...

Java library for parsing & building logical expressions

I am looking for an open source library in Java for parsing and building sql like expressions. for example to evaluate validity of expressions like: "(a = x or y ) and (b != z)" in addition I want to have an API for building or extending expressions. something like: Expression exp = new Expression(); exp.addCondition("a",{"x","y"...

Best Way to get XML from a JDBC resultset

I'm looking for the best approach to getting an XML document from a JDBC resultset. The structure of the XML isn't awfully important, but it should be fairly speedy. For clearification, I would like the data from the resultset and only enough metadata to identify the data (field names essentially). I'm working with MySQL, DB2, SQL Serve...

Is there tooling to visualize a live Spring application context?

Are there any tools that can take a fully-constructed/wired Spring application context and export a visualization of it? I'm talking about a live context that shows the order in which aspects were applied, what beans were auto-wired into other beans, etc. I know it can be done with the context files themselves (re: Spring IDE). However,...

Are there any good ant visualization programs out there?

I am looking for a utility that will suck in an ant build file and present a graphical display of the targets and properties available to that target. Please don't respond with 'VisualAnt' I own it and it sucks. ...

Is it possible to manage C++ application via JMX ?

We have a distributed application containing C++ and Java modules, interacting via CORBA. Are there any C++ libraries/tools for exposing "variables" and "methods" to JMX tools (to create unigfied management) ? ...

where can i learn about how memory management in java works?

what i'm looking for is what gets put into the call stack once a function is called recursively, how the arguments are laid on top of each other (are local variables pushed in order? are paremeters pushed in the reverse order?), what bytes exist in an array besides those you asked to have for... searching on the internet, i've only fou...

How do I view JRE's source code in Eclipse?

Using Eclipse I want to view the source code for a core Java class (E.g. java.util.concurrent.ConcurrentHashMap) but when I navigate to the source using 'Open Declaration' it says 'Source not found' and gives me the option to attach the source. My question is; how do i attach the source? Where do i get the source .jar from for the java....

Best "3D display" developing environment for Java? (do they even exist?)

There is a bunch of announcements from CES 2009 about new 3D displays used for games and movies. I was wondering if there is a setup that currently exist that also brings the 3D to a development environment. Such an environment would, for example, bring out compile errors to the front. Or maybe allow the programmer to quickly stack panel...

Seeding java.util.Random with consecutive numbers

I've simplified a bug I'm experiencing down to the following lines of code: int[] vals = new int[8]; for (int i = 0; i < 1500; i++) vals[new Random(i).nextInt(8)]++; System.out.println(Arrays.toString(vals)); The output is: [0, 0, 0, 0, 0, 1310, 190, 0] Is this just an artifact of choosing consecutive numbers to s...

Do line endings differ between Windows and Linux?

Hi all, I am trying to parse the linux /etc/passwd file in java. I'm currently reading each line through the scanner class in java and then using string.split() to delimit each line. The problem is that the line "list:x:38:38:Mailing List Manager:/var/list:/bin/sh" is treated by the scanner as 3 different lines: 1) "list:x:38:38:Maili...

AI Game Opinion (kind of homework related)

I have taken an AI course, and the teacher asked us to implement a game that makes use of one of the AI algorithms. Here is where I need a bit of help: I don't know to what kind of games each algorithm is applied if you could just give an example of a game or game type and the algorithm it uses, I would appreciate it I don't need an...

How can I call java from asp?

I'm not familiar with ASP, but am helping someone out with their website as a side project. I am trying to call Apache FOP (a java application) from ASP using VB. I have seen simple examples using the GetObject('java:...') constuct, but I don't know how to pass and retrieve binary data from a java object. Ideally, I would do this all ...

Trouble defining a generic interface

I have been struggling for some time trying to define a generic interface, but I fail to achieve what I want. The following is a simplified example of the problem. Let's say I have a generic Message class public class Message<T> { private T content; public void setContent(T content) { this.content = content; } p...

Best framework for simple UI application with multiple configurations

I'm looking to make a selection of a (Java-based) framework for UI development, with the following constraints: The application requires very simple UI (form with 1 or 2 buttons results in a list of images, texts, etc) but the actual types of UI element rendered are numerous. We already have the backend logic (in the form of a web serv...