java

writing test case for a DAO on a J2ee Application

I am trying to write some test cases for my DAO classes in a J2EE applications. Methods in my DAO classes try to get connection to the Database based on a JDBC URL (which is on the app server). So from the front end if I click bunch of stuff and make the DAO trigger it runs fine. However, when I write tests cases for the DAO and the D...

Problems with jar

I have a project in Eclipse, that inculdes some files with data(not in classpath), and I want to pack this project to the runnable jar-file, but the problem is, that after I pack it to the jar, it's not located there. How can i add it to the jar? ...

Gwt connector for pallete example

Hi, I am trying to add gwt-connector function to my project. My project is similar to the following example: PaletteExample When ever i try to add Shape() function to the widgets it is not working. Any suggestion will be appreciated. Thank you. ...

When there is two for() loop, the second one doesn't work.

Hi, Here are my for() loops : public void showMovementCase(){ int movePlusAttack = moveAllowed+attackDistance; int twiceMoveAllowed = (moveAllowed)*2; for(int i = 0; i <= movePlusAttack*2; i++){ for(int j = 0; j <= movePlusAttack*2;j++){ boolean a = movePlusAttack <= j+i && movePlusAttack >= j-i && i <= movePlusAttack; boole...

Good problem domain for introduction to OO project?

I'm working with someone who's looking to get back into programming after several years of IT support work. They know all the iterative programming basics and have used them frequently, but their only object-oriented programming experience was in college. The goal is to come up with a decent-sized project that is good for illustrating ...

Testing ServiceLocator using JUnit

This is a follow up question to my previous question. I am trying to write test case for my ServiceLocator class but it gives me the following error: com/iplanet/ias/admin/common/ASException java.lang.NoClassDefFoundError: com/iplanet/ias/admin/common/ASException at java.lang.ClassLoader.defineClass1(Native Method) My test ca...

Java performance in numerical algorithms

hello again I am curious about performance of Java numerical algorithms, say for example matrix matrix double precision multiplication, using the latest JIT machines as compared for example to hand tuned SSE C++/assembler or Fortran counterparts. I have looked on the web but most of the results come from almost 10 years ago and I under...

How to make an accepted socket non-blocking in java

I am accepting a connection from a client and then passing that connected socket off to another object, however, that socket needs to be non-blocking. I'm trying to use getChannel().configureBlocking(false) but that does not seem to be working. It needs to be non-blocking because this the method below is called every 100ms. Is there s...

How to ask 2-dimensional Java array for its number of rows?

How should I go about asking a 2-dimensional array how many rows it has? ...

Iterate over functions

Is something like this possible to do in Java? for (Object o : objects) { for (Function f : functions) { f(o); } } I'm only calling a handful of functions, but I need to compose them, like so: for (Object o : objects) { for (Function f : functions) { for (Function g : functions) { f(g(o)); } } } And I'd li...

Add Principal/authority dynamically for anonymous user

Hi Guru, I am using spring security 2.x (+spring + struts2) and would like to enable add authority to user dynamically after user submits a form. I have a protected directory (/protected/dir/) which is protected by ROLE_USER <sec:intercept-url pattern="/protected/dir/**" access="ROLE_USER, ROLE_ADMIN" /> Which user can access after ...

Error saving image into Google App Engine/Java

I'm trying to make following JDO entity in GAE/J (I'm using Gilead). package test.domains; import java.io.Serializable; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.Prim...

Getting Nexus to download dependencies from a repository with no .index file

I've just setup the latest version of Nexus for our company, and it's working great. We've added several 3rd party repositories, and one of them does not have an .index file present. So it appears that Nexus can't index it, nor can the local maven ask for deps in that repository. Definitely unfortunate. Is there any way around this a...

way to make a function aware who called it

in java is it possible to make a method aware of who called it (without changing parameters) and then return something else? public class MyClassA { public static final String someStirng = "this is some String" public String getSomeString () { return someString; } } public class MyClassB extends MyClassA { public...

Swing object: first setText() gets "stuck" when using Mac Java SE 6

Hi there, I am a Java newbie trying to maintain an application that works fine under J2SE 5.0 (32- and 64-bit) but has a very specific problem when run under Java SE 6 64-bit: [Tims-MPB:~] tlynch% java -version java version "1.6.0_15" Java(TM) SE Runtime Environment (build 1.6.0_15-b03-226) Java HotSpot(TM) 64-Bit Server VM (build 14.1...

How to cast rays given an arbitrary camera?

I'm writing a ray tracer (using left-handed coordinates, if that makes a difference). It's for the sake of teaching myself the principles, so I'm not using OpenGL or complex features like depth of field (yet). My camera can have an arbitrary position and orientation; I indicate them by way of three vectors, location, look_at, and sky, wh...

Mapping Java with JAXB annotations to XSD keys/keyrefs

We are using JAXB to map Java classes into XML files. Currently we use the Java-to-XSD approach by annotating the Java classes. This works fine in general but we've hit the following problem now: we want an attribute of one XML element to refer to another XML element by it's name/ID. Imagine some XML describing a conceptual schema, with...

How to remove HTML tag in Java

Is there the regular expression that can completely remove a HTML tag? By the way, I'm using Java. ...

I Want to get a week value

I wan to get the value of only one week. I am using the following JPA query: SELECT a FROM questions.dao.hibernate.Questions a WHERE (a.posted_date-CURRENT_DATE)>= 7 But I am getting an error message like org.hibernate.QueryException: could not resolve property: posted_date of: questions.dao.hibernate.Questions [SELECT a FROM qu...

Nested Data Structure Problem

I have the following code: class A { IListB list; A( IListB list ) { this.list = list; } } interface IListA {} class EmptyListA implements IListA { EmptyListA() {} } class ListA implements IListA { A first; IListA rest; ListA( A first, IListA rest ) { this.first = first; this.rest...