java

Getting an int representation of a String

Hi I am looking for a way to create an int\long representation of an arbitrary alpha-numeric String. Hash codes won't do it, because I can't afford hash collisions i.e. the representation must be unique and repeatable. The numeric representation will be used to perform efficient (hopefully) compares. The creation of the numeric key wi...

How to export findbugs results from Eclipse findbugs plugin?

I have findbugs plugin for eclipse which when run on my project will show results in Bugs explorer clubbed by the type of bug. I need to be able to do two things: Export all these to excel sheet Find out the bugs reported in a set of files (and be able to do it recursively w/o running for whole project and exporting and finding out th...

Should I avoid using Java Label Statements?

Today I had a coworker suggest I refactor my code to use a label statement to control flow through 2 nested for loops I had created. I've never used them before because personally I think they decrease the readability of a program. I am willing to change my mind about using them if the argument is solid enough however. What are people's ...

Can you programmatically restart a j2ee application?

Does anyone know if it is possible to restart a J2EE application (from the application)? If so, how? I would like to be able to do it in an app-server-agnostic way, if it is possible. The application will be run on many different app servers-- basically whatever the client prefers. If it isn't possible to do this in an app-server-agn...

Does anyone here have a favorite memory profiling/memory leak tool they like to use for their java webapps?

I'm looking for a good tool to profile a java webapp. I'd like to get performance information and memory usage if possible. Any suggestions? ...

How do you send email from a Java app using Gmail?

Is it possible to send an email from my Java application using a Gmail account? I have it configured to send using my company mail server, but that's not going to cut it when I distribute the application. Answers using Hotmail or Yahoo mail are also acceptable. ...

Tools for converting non-Java into Java source

Are there any good tools out there for automatically converting non-Java source code into Java source? I'm not expecting something perfect, just to get the worst of the grunt work out of the way. I guess there is a sliding scale of difficulty. C# should be relatively easy (so long as you ignore all the libraries). (well written) C++ no...

Iterate Over Map

If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of elements depend on the specific map implementation that I have for the interface? ...

What languages support covariance on inherited methods' return types?

I discovered that the cause of my problems (see question) was the lack of support in C# for covariance on inherited methods' return types. Now I'm curious what languages support this feature. Accepted answer will be whoever can name the most. EDIT: John Millikin correctly pointed out that lots of dynamic languages support this. I'll ...

Sprintf equivalent in Java

Printf got added to Java with the 1.5 release but I can't seem to find how to send the output to a string rather than a file (which is what sprintf does in C). Does anyone know how to do this? ...

Customising log4j adapter

I want to build my own custom log4j (network) adapter to solve my problem that I posted here. I have looked at the documentation on the log4j and I cant see where/if the developers go into how to do this. Can anyone point me in the right direction to get started? ...

How to monitor the computer's cpu, memory, and disk usage in Java?

I would like to monitor the following system information in Java: current cpu usage** (percent) available memory* (free/total) available disk space (free/total) *note that I mean overall memory available to the whole system, not just the JVM I'm looking for a cross-platform solution (Linux, Mac, Windows) that doesn't rely on my own ...

JUnit for database code

I've been trying to implement unit testing and currently have some code that does the following: query external database, loading into a feed table query a view, which is a delta of my feed and data tables, updating data table to match feed table my unit testing strategy is this: I have a testing database that I am free to manipula...

Practical Experience using Stripes?

I am coming from an Enterprise Java background which involves a fairly heavyweight software stack, and have recently discovered the Stripes framework; my initial impression is that this seems to do a good job of minimising the unpleasant parts of building a web application in Java. Has anyone used Stripes for a project that has gone li...

java String concatenation

I'm curious and wasn't sure, so i thought id ask: assuming String a and b. a+=b a.concat(b) Under the hood are they the same thing? Edit: Here is concat decompiled as reference, I'd like to be able to decompile the + operator as well to see what that does, not sure how to do that yet. public String concat(String s) { ...

Tomcat vs Weblogic JNDI Lookup

The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds". For development (localhost), we might be running Tomcat and when declared in the <context> section of server.xml, Tomcat will hang JNDI datasources on "java:comp/env/jdbc/*" in the JNDI tree. Problem: in Weblogic, the JNDI lookup is "app...

Reconnecting JMS listener to JBossMQ

We have a Java listener that reads text messages off of a queue in JBossMQ. If we have to reboot JBoss, the listener will not reconnect and start reading messages again. We just get messages in the listener's log file every 2 minutes saying it can't connect. Is there something we're not setting in our code or in JBossMQ? I'm new to JMS s...

Returning from a finally block in Java

I was surprised recently to find that it's possible to have a return statement in a finally block in Java. It seems like lots of people think it's a bad thing to do as described in 'Don't return in a finally clause'. Scratching a little deaper, I also found 'Java's return doesn't always' which shows some pretty horrible examples of othe...

What are advantages of bytecode over native code?

It seems like anything you can do with bytecode you can do just as easily and much faster in native code. In theory, you could even retain platform and language independence by distributing programs and libraries in bytecode then compiling to native code at installation, rather than JITing it. So in general, when would you want to execu...

Video Thumbnails in Java

I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated. Is there an easy way to do it? What about codecs? Will I have to deal with it? Any video type is suported? (including Quicktime) ...