java

What is the best way to parse a date in MM/DD/YY format and adjust it to the current / previous century?

One of our customers wants to be able to enter a date with only 2 digits for the year component. The date will be in the past, so we want it to work for the previous century if the 2 digit year is after the current year, but work for the current century if the 2 digit year is equal to or less than the current year. as of today 10/30/200...

Is there a way to separate long running (e.g. stress tests) out so they're not run by default in Maven 2?

We've had an ongoing need here that I can't figure out how to address using the stock Maven 2 tools and documentation. Some of our developers have some very long running JUnit tests (usually stress tests) that under no circumstances should be run as a regular part of the build process / nightly build. Of course we can use the surefire ...

Running Eclipse Junit Plugin tests with Junit 4.4 or newer -- why aren't tests detected?

I need to use JUnit 4.4 (or newer) in a set of eclipse plugin tests, but I've run into the following problem: Tests are not detected when running with the junit 4.4 or 4.5 bundles from springsource ([junit44] and [junit45]). The org.junit4 bundle that can be obtained with eclipse supplies junit 4.3 (as of Ganymead / Eclipse 3.4). The ...

Programmatically generate an Eclipse project

I use eclipse to work on an application which was originally created independently of eclipse. As such, the application's directory structure is decidedly not eclipse-friendly. I want to programmatically generate a project for the application. The .project and .classpath files are easy enough to figure out, and I've learned that proje...

Java -> Apache Commons StringEscapeUtils -> escapeJavaScript

For a very simple ajax name lookup, I'm sending an id from the client webpage to the server (Tomcat 5.5, Java 5), looking it up in a database and returning a string, which is assigned to a javascript variable back in the client (and then displayed). The javascript code that receives the value is pretty standard: //client code - javascr...

javax.jms does not exist - compiling activemq examples

I'm trying to compile the examples that come with activemq in apache-activemq-5.1.0\example\src\ TopicPublisher.java, CommandLineSupport.java on compiling thru netbeans it has some referencing problems saying javax.jms does not exist. I've tried the j2ee.jar, openjms, sun jms but they all give the same error. its also complaining ab...

Java Generics (Wildcards)

I have a couple of questions about java generics wildcards: 1) whats the difference between List<? extends T> and List<? super T> 2) What is a bounded wildcard and what is an unbounded wildcard? Thanks! ...

What would be the best way to match up two object instances between two different applications in a J2EE server?

I have a J2ee application where I basically want two objects, created by two separate servlets to communicate directly and I need these intances to be stable, i.e. to "know" each other during the session. The sequence is roughly: Client sends a request to Servlet #1, which creates object A Client sends a second request (after the fir...

How do you run Lucene on .net?

Lucene is an excellent search engine, but the .NET version is behind the official Java release (latest stable .NET release is 2.0, but the latest Java Lucene version is 2.4, which has more features). How do you get around this? ...

java.sql.Connection extension for SSH

I have a MySQL database behind a firewall which can only be accessed via an SSH connection. Does anyone know of an implementation of java.sql.Connection which would allow me to make an SSH connection to this database? ...

Why can't I call a method outside of an anonymous class of the same name

The code at the end produces a compile error: NotApplicable.java:7: run() in cannot be applied to (int) run(42); ^ 1 error The question is why? Why does javac think I am calling run(), and does not find run(int bar)? It correctly called foo(int bar). Why do I have to use NotApplicable.this.run(42);?...

What is the best way to protect user inputs (not yet submitted) from session timeout?

I develop and maintain small intranet web apps(JSP and Resin). Some users takes so much time to complete the forms that, when they submit, they lose all their input data because of session timeout. Currently I prolonged session timeout to 30 minutes and display count-down clock till session timeout on top of the page, but, I think th...

restarting a java console application

At the moment I have a console application. I would like to be able to exit the application, update through svn, recompile and then relaunch. This is running under a Linux environment. At the moment I'm not sure how I would be able to relaunch the application. Is there a way to do this? ...

JSF & Facelets Flow

I have a dynamic Facelets page that needs to show information from database when the page loads. At this point in the flow, there have not been any form submissions. Every JSF example I can find only shows a form submission with dynamic results on the next page. Every call I make to our database is currently takes place after an action ...

Advanced Java Generics question: why do we need to specify redundant information

Hi, I've got some generic class for my JPA model POJO that goes like this: public interface Identifiable<PK extends Serializable> { PK getUniqueId(); } public interface GenericDao<T extends Identifiable<PK>> { public T findById(PK id); } This code won't compile. For this to work, I need to specify public interface GenericD...

Syntax colouring using Swing

Is it possible to have something like a JTextArea which will color some keywords based on some mappings I have ? ...

How do you change the CLASSPATH within Java?

How do you change the CLASSPATH of a Java process from within the Java process? Before you ask me "Why would you want to do that?" I'll explain it shortly. When you have a Clojure REPL running it is common to need more jars in your CLASSPATH to load a Clojure source file, and I'd like to do it without having to restart Clojure it...

Eclipse 3.4 TextViewer

I am creating a plugin for Eclipse 3.4. I created a plug-in development project using the application with a view. Now I am trying to create a TextViewer the documentation says that it is located in org.eclipse.jface.text.TextViewer. But, this whole package is missing and eclipse cannot locate TextViewer class to import. I want to kn...

Debugging getResource*

How do you debug getResource-style methods that are failing, returning null? I am sure the file it's looking for is there, but it's returning NULL. How do I know what it is looking for to try to spot any mismatch? ...

Tips for using vim as a Java IDE?

I'm addicted to vim, it's now my de facto way of editing text files. Being that it's mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing java apps. Some questions I have: How do I invoke a maven task without leaving vi Can I get code completion? How's the syntax highlighting? Anythi...