java

Internals of Spring Framework and other IoC containers

I've been using spring for some time, but I always wondered how does it work, more specifically, how do they load and weave beans/classes marked only with an interface or @annotation. For the xml declarations, it's easy to see how spring preprocesses my beans (they are declared in the xml context that spring reads), but for the classes...

Saving different csv files as different sheets in a single excel workbook

Related to this question, how to save many different csv files into one excel workbook with one sheet per csv ? I would like to know how to do this programmatically in Java. ...

How to handle calendar TimeZones using Java?

I have a Timestamp value that comes from my application. The user can be in any given local TimeZone. Since this date is used for a WebService that assumes the time given is always in GMT, I have a need to convert the user's parameter from say (EST) to (GMT). Here's the kicker: The user is oblivious to his TZ. He enters the creation dat...

What can you not do on the Dalvik VM (Android's VM) that you can in Sun VM?

I know that you can run almost all Java in Dalvik's VM that you can in Java's VM but the limitations are not very clear. Has anyone run into any major stumbling blocks? Any major libraries having trouble? Any languages that compile to Java bytecode (Scala, Jython etc...) not work as expected? ...

Filtering warnings in eclipse by filename

We use Eclipse for our Java development, and we've got Maven compiling our JSPs into servlets to be used in our embedded Jetty instance. This means that to run the project from Eclipse, I have to include ./target/jsp-source as a source folder, which works great. The warnings that show up for that generated code are everywhere though, and...

Java 1.6 SDK on Mac OS 10.5

Has Java 1.6 SDK been released for mac? I can't seem to find it... ...

How is Jmock used with HttpSession and HttpServletRequest

I am new to jmock and trying to mock an HttpSession. I am getting: java.lang.AssertionError: unexpected invocation: httpServletRequest.getSession() no expectations specified: did you... - forget to start an expectation with a cardinality clause? - call a mocked method to specify the parameter of an expectation? the test method: @Tes...

Restrict postges access from java clients by using java program on a server

Hi community, Perhaps this question is not very clear but I didn't find better words for the heading, which describes the problem I like to deal with shortly. I want to restrict access from a java desktop application to postgres. The background: Suppose you have 2 apps running and the first Application has to do some complex calcula...

Javascript classes and DWR

I've been playing with DWR and converters for a while and I really wanted to map my Java classes to JavaScript classes. Using DWR converters, I have the option to point out what is the name of my JS constructor given a Java class. So far so good... The problem arises when my JS constructor is within a JS package-like name (just like YUI'...

HashSet problem -- equals and hashCode with contains working differently than I'd expect

I have the following code: class IncidentTag: def __init__(self,tag): self.tag = tag def equals(self,obj): return self.tag.equals(obj.tag) def hashCode(self): return self.tag.hashCode() from java.lang import String from java.util import HashMap from java.util import HashSet tag1 = IncidentTag(Str...

Android API for detecting new media from inbuilt camera & mic

Is there any elegant way in the Android API for detecting new media when it is written to the device? I’m mainly interested in photos taken by the camera, video taken by the camera and audio recorded from the mic. My current thinking is to periodically scan each media content provider and filter based on last scan time. I’m just wonder...

Lightweight Java Object cache API

Question I'm looking for a Java in-memory object caching API. Any recommendations? What solutions have you used in the past? Current Right now, I'm just using a Map: Map cache = new HashMap<String, Object>(); cache.put("key", value); Requirements I need to extend the cache to include basic features like: Max size Time to live ...

Best way to throw exceptions in JNI code?

I'd like a consistent and simple way to throw exceptions in JNI code; something that handles chained exceptions (implicitly from the env->ExceptionOccurred method, or explicitly by parameters, either way is good) and saves me looking up constructors every time I want to do this. All of the above is preferably in C, although I could tran...

Getting template text from FreeMarker in Spring app

Hi, In my Spring app, I'd like to use FreeMarker to generate the text of emails that will be sent by my application. The generated text will never be returned to the view so I don't need to configure a FreeMarker view resolver. The documentation seems to indicate that I should configure a FreeMarkerConfigurationFactoryBean like this <b...

Is there a memory efficient replacement of java.lang.String?

After reading this old article measuring the memory consumption of several object types, I was amazed to see how much memory Strings use in Java: length: 0, {class java.lang.String} size = 40 bytes length: 7, {class java.lang.String} size = 56 bytes While the article has some tips to minimize this, I did not find them entirely satisfy...

Has anyone used or written an Ant task to compile (Rhino) JavaScript to Java bytecode?

I'd like to use the Rhino JavaScript compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and jythonc tasks for Groovy, NetREXX(!) and Jython, respectively. Has anyone used or written such an Ant task, or can anyone provide some tips...

How to join another MySQL table when using Master/Detail Sample Form in Netbeans?

I am trying to implement an application by using MySQL/JAVA and I found this tool in netbeans to easily create a new form for an existing table. (edit, insert, delete etc.) Is there an easy way to modify the code to join another table to display fields from that table. Example: I have an employee table that has a foreign key TitleID and...

Force look and feel on NetBeans 6.5

How do you for a specific look and feel on NetBeans 6.5? I mean by passing flags to the netbeans script (on Ubuntu) or by modifying the netbeans script or by some setup. ...

How to handle huge result sets from database

I'm designing a multi-tiered database driven web application – SQL relational database, Java for the middle service tier, web for the UI. The language doesn't really matter. The middle service tier performs the actual querying of the database. The UI simply asks for certain data and has no concept that it's backed by a database. The qu...

Finding numerical substrings mathematically, without string comparison.

This originally was a problem I ran into at work, but is now something I'm just trying to solve for my own curiosity. I want to find out if int 'a' contains the int 'b' in the most efficient way possible. I wrote some code, but it seems no matter what I write, parsing it into a string and then using indexOf is twice as fast as doing it...