java

How to detect intermittent time out problem in web applications?

Have a n-tire web application and search often times out after 30 secs. How to detect the root cause of the problem? ...

Automagic unit tests for upholding Object method contracts in Java?

When developing Java applications, I often override Object methods (usually equals and hashCode). I would like some way to systematically check that I'm adhering to the contract for Object methods for every one of my classes. For example, I want tests that assert that for equal objects, the hash code is also equal. I'm using the JUnit...

Is java.util.regexp efficient enough?

I need to do a lot of searches of certain patterns in source files while the user is changing them, so I need to do regexp matching that is efficient in time and memory. The pattern repeats itself so should be compiled once, but I need to be able to retrieve subparts (rather than just confirm a match) I'm considering using java.util.reg...

JUnit and junit.framework.TestSuite - No runnable methods

I've made some unit tests (in test class). The tutorial I've read said that I should make a TestSuite for the unittests. Odd is that when I'm running the unit test directly (selecting the test class - Run as jUnit test) everything is working fine, altough when I'm trying the same thing with the test suite there's always an exception: ja...

Is String.hashCode() portable across VMs, JDKs and OSs?

An interesting issue came up recently. We came across some code that is using hashCode() as a salt source for MD5 encryption but this raises the question: will hashCode() return the same value for the same object on different VMs, different JDK versions and operating systems? Even if its not guaranteed, has it changed at any point up t...

Storing more than 1 data item at a single index in a linked-list?

I am trying to store more than 1 data item at a single index in my linked-list. All of the examples in my textbook seem to illustrate adding only 1 piece of data per index. I'm assuming it is possible to add more? For example, using the Collections API to store an integer I would do the following: LinkedList <Integer>linky = new Link...

Java, Alfresco Web Service API and Unicode NamedValues

I'm using Java for accessing Alfresco content server via it's web service API for importing some content into it. Content should have some NamedValue properties set to UTF-8(cyrillic) string. I keep getting the Sax parser exception: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x1b) was found in the element content ...

Java: Threading Techniques & Concepts

When using threads I sometimes visualise them as weaving together 3 or more dimensional interconnections between Objects in a Spatial context. This isn't a general use case scenario, but for what I do it is a useful way to think about it. Are there any APIs which you use which aid threading? Have you used threads in a manner which doe...

How to go about mocking a class with final methods?

Say I have class A with class A { final String foo() { // .. computing result, contacting database, whatever .. return "some computed value"; } // ... and a bazillion other methods, some of them final. } Now I have class B with class B { String methodIWantToTest(A a) { String output = a.foo(); // ... whate...

What is the easiest way to parse an INI file in Java?

I am writing a drop-in replacement for a legacy application in Java. One of the requirements is that the ini files that the older application used have to be read as-is into the new Java Application. The format of this ini files is the common windows style, with header sections and key=value pairs, using # as the character for commenti...

How should I configure Jetty 7 pre3 to use oracle JDBC source?

All stuff is running under Windows XP Pro SP2/32-bit. I have downloaded Jetty 7 pre3 from http://dist.codehaus.org/jetty/jetty-7.0.0-prereleases/jetty-7.0.0pre3/jetty-assembly-7.0.0pre3.zip>dist.codehaus.org. I have extracted jetty to C:\jetty-7.0.0pre3\ (so I have C:\jetty-7.0.0pre3\bin\ and other dirs) I have put my webapp into C:\jet...

Do I need to worry about the String Constant Pool?

I have a Java application that's very String-heavy - it takes a feed of huge numbers of big, different String objects. Do I need to worry about the String Constant Pool for memory and performance? Is there any way to see how big the pool is at any point? ...

Is it possible to add to the available parameters of a request (HttpServletRequest)

I want to intercept a request in a filter/servlet and add a few parameters to it. However, the request does not expose a 'setParameter' method and the parameter map when manipulated throws an error saying it is locked. Is there an alternative I can try? ...

What JDBC tools do you use for synchronization of data sources?

Hello. I'm hoping to find out what tools folks use to synchronize data between databases. I'm looking for a JDBC solution that can be used as a command-line tool. There used to be a tool called Sync4J that used the SyncML framework but this seems to have fallen by the wayside. ...

How to stop java process gracefully?

How to stop java process gracefully in Linux and Windows? When does Runtime.getRuntime().addShutdownHook gets called, and when it does not? What about finalizers, do they help here? Can I send some sort of signal to java process from shell? I am looking for preferably portable solution. Thanks, ...

How do you version your projects and manage releases?

Our situation is as follows, but I'm curious about this problem in any situation. We have a framework consisting of 4 projects: beans util framework web We also have modules that need a version and depend on a version of beans and util. Finally we have a customer project that consists of a specific version of the core projects and ...

How does one weed out dependencies in a large project?

I'm about to inherit a rather large Java enterprise project that has a large amount of third party dependencies. There is at least seventy JARs included and some of them would seem to be unused e.g. spring.jar which I know isn't used. It seems that over the years as various developers have touched upon the code base they have all tried ...

What is the best free Java based bug tracker?

For internal development team I'm looking for a bug tracker. Important requirements are: Free (must have) WAR/EAR-deployable (must have; support team prefers to have all apps deployed same way) Nice UI (nice to have) UPDATE Since I wrote this, Atlassian has introduced a $10 (ten, not ten thousand!) version of JIRA for 10 developers...

How do I get rid of the mouse cursor in full-screen exclusive mode?

I'm working on a simple 2D game engine in Java, and having no trouble with FSEM, buffer strategies, and so on; my issue is with the mouse cursor. In windowed mode, I can hide the mouse cursor, no problem, by using setCursor() from my JFrame to set a wholly-transparent cursor. However, after a call to device.setFullScreenWindow(this) to g...

C# - Java interoperation

Can you give me some pointers on making C# code and Java code interoperate? Let's define the interoperation as something simple: allow (from Java code) the instantiantion and method calling of a class defined in C#, and, possibly, the other way around as well. Is this even possible natively? (i.e. without some proxy/skeleton interface ...