java

Message delivery when user is offline

I have a plugin for OpenFire that creates and delivers a message to a user using XMPPServer.getInstance().getMessageRouter().route(message) What I would like to know is what happens to that message if the user is not online. My goal is to only have the message delivered if the user is online, and fail or be routed to the bit bucket...

open source cms

Has anyone ever used any Java based open soure cms tools? I am evaluating jackrabbit specifically. Does anyone have any thought on it or know something that is better? ...

Is there a perferred method to update apps that use an EJB?

I have a java app that works with an EJB, however if: The EJB gets updated, the app is broken. The app server is updated, the app is broken. Without human involvement, is there a preferred method to update the client jars for the app server and bean? If there preferred method depends on the app server, then assume jboss. ...

Should I catch exceptions thrown when closing java.sql.Connection

Connection.close() may throw SqlException, but I have always assumed that it is safe to ignore any such exceptions (and I have never seen code that does not ignore them). Normally I would write: try{ connection.close(); }catch(Exception e) {} Or try{ connection.close(); }catch(Exception e) { logger.log(e.getMessag...

Method Overloading. Can you overuse it?

What's better practice when defining several methods that return the same shape of data with different filters? Explicit method names or overloaded methods? For example. If I have some Products and I'm pulling from a database explicit way: public List<Product> GetProduct(int productId) { // return a List } public List<Product> G...

ASP.NET MVC framework port for Java EE?

So I've played some with the new, not yet final release of ASP.NET MVC framework and I find it to be very nice and elegant. However at work we are tied to Java for the time being, so I'm wondering this: is there a port of the framework out there for Java people like myself? I realize that webforms isn't going to be available unfortunatel...

Java GUI LayoutManagers

I'm busy with an asignment where i have to make a graphical interface for a simple program. But i'm strugling with the layout. This is the idea: What is the easiest way to accomplish such a layout? And what method do you use to make layouts in java. Just code it, or use an IDE like netbeans? ...

java thread question

I have some thread-related questions , assuming the following code (please ignore the possible inefficiency of the code,I'm only interested in the thread part): //code without thread use public static int getNextPrime(int from) { int nextPrime = from+1; boolean superPrime = false; while(!superPrime) { boolean prime = t...

Open Browser window from Java program

Question I have an application written in Java. It is designed to run on a Linux box standalone. I am trying to spawn a new firefox window. However, firefox never opens. It always has a shell exit code of 1. I can run this same code with gnome-terminal and it opens fine. Background So, here is its initialization process: Start ...

When using Spring Security, what is the proper way to obtain current username (i.e. SecurityContext) information in a bean?

I have a Spring MVC web app which uses Spring Security. I want to know the username of the currently logged in user. The code snippet below is what I'm doing. My question is, is this the accepted way? I don't like having a call to a static method inside this controller - that defeats the whole purpose of Spring, IMHO. Is there a w...

Netbeans GUI Designer & Fixed-Size Application Panels

I'm having a problem, creating a fixed-size overall panel for a touchscreen GUI application that has to take up the entire screen. In a nutshell, the touchscreen is 800 x 600 pixels, and therefore I want the main GUI panel to be that size. When I start a new GUI project in NetBeans, I set the properties of the main panel for min/max/pr...

Finding unused jars used in an eclipse project

Are there any plugins/tools available to go through the classpath of an eclipse project (or workspace) and highlight any unused jars? ...

Alternative to deprecated javax.servlet.http.HttpUtils.parseQueryString?

I am looking to parse a URL to obtain a collection of the querystring parameters in Java. To be clear, I need to parse a given URL(or string value of a URL object), not the URL from a servlet request. It looks as if the javax.servlet.http.HttpUtils.parseQueryString method would be the obvious choice, but it has been deprecated. Is the...

Do you use curly braces for additional scoping?

I mean other than using it when required for functions, classes, if, while, switch, try-catch. I didn't know that it could be done like this until I saw this SO question. In the above link, Eli mentioned that "They use it to fold up their code in logical sections that don't fall into a function, class, loop, etc. that would usually be ...

Java IPC: GUI and Command Line

I would like to implement a command line interface for a Java application. This wouldn't be too difficult to do, except I would like the command line program to affect the state of another Java GUI program. So for example, I could type: java CliMain arg1 arg2 And another running GUI instance would perform an appropriate action. What ...

Java memory consumption, "top" and HP-Ux

We ship Java applications that are run on Linux, AIX and HP-Ux (PA-RISC). We seem to struggle to get acceptable levels of performance on HP-Ux from applications that work just fine in the other two environments. This is true of both execution time and memory consumption. Although I'm yet to find a definitive article on "why", I believe ...

Jython 2.2.1, howto move a file? shutils.move is non-existant!

'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython? ...

How to disable array bounds checking in opensource Java?

Now that Java is open source, one of the first things I would like to do is to disable array bounds checking for certain blocks of code, where I'm dead sure I cannot go offbounds and where performance heavily matters. Now, I'm not a compilers/grammar expert, so any syntax would be good enough for me: Here's one that I can think of: pra...

When using Eclipse with FindBugs can you mark a bug as not a bug and have it removed from the bug list?

FindBugs has found a potential bug in my code. But it is not a bug. Is it possible to mark this occurrence as 'not a bug' AND have it removed from the bug list? I have documented quite clearly why for each case it is not a bug. For example. A class implements the comparable interface. it has the compareTo method. I have however not ov...

How do I copy built artifact to a directory on remote Windows server in maven deploy phase?

Hello, could someone provide working example (full maven plugin configuration) how to copy built jar file to a specific server(s) at the time of deploy phase? I have tried to look at wagon plugin, but it is hugely undocumented and I was not able to set it up. The build produces standard jar that is being deployed to Nexus, but I need t...