java

Clean way to combine multiple jars? Preferably using ant

I have runtime dependencies on some external jars that I would like to "rejar" into a single jar. These external dependencies are stored in a external_jars directory, and I'd like to be able to not have to list each one out (e.g., to not need to change my build scripts if my dependencies change). Any thoughts? Google gave me a good answ...

server side validation in java web application

How we can validate the our jsp form before storing the data in database ...

Multiple ways to move through an Iterator

Hi, When I use an Iterator of Object I use a while loop (as written in every book learning Java, as Thinking in Java of Bruce Eckel): Iterator it=... while(it.hasNext()){ //... } but sometime i saw than instead somebody use the for loop: Iterator it=... for (Iterator it=...; it.hasNext();;){ //... } I dont' understand this...

limit map key and value types - more complicated

I have a more complicated issue (than question 'Java map with values limited by key's type parameter' question) for mapping key and value type in a Map. Here it is: interface AnnotatedFieldValidator<A extends Annotation> { void validate(Field f, A annotation, Object target); Class<A> getSupportedAnnotationClass(); } Now, I want to...

Use something else than JDBC over firewall

Hi, I have simple server-client application that uses JDBC to connect to database and things works ok. Application does few simple things with JDBC connection (get data, insert new line and few others). Now, I would like to keep the same application but use it outside of firewall - so, I would put something else on some host:port (and ...

Speed: Java serialization or csv?

I have a large array of Java simple structs (consists of just primitive members) and I need to save and load them from and to a file What would be faster, implementing java.io.Serializable and using read/writeObject or overriding toString() / toCSV(), adding a new constructor and reading/writing to text file? I want to avoid b...

My own classloader?

Here is the problem I'm running into. There's a huge legacy application that runs on java 1.3 and uses external API, say, MyAPI v1.0. The exact implementation of MyAPI 1.0 is located somewhere in the classpath used by the app. There's also a mechanism that allows that app to use external code (some kind of plugin mechanism). Now I have a...

best practices for AJAX framework implementation

What are the best-practices in implementation of AJAX framework and handling 'special' cases as: Session timeout on AJAX call (redirect to login page, error, ignore...) Server exceptions in AJAX request Server session state in multiple following AJAX calls Browser reload of page where AJAX calls has...

Debugging Datastructures Visually

I've got some Java code which builds a data structure (approx 500 small interlinked objects) from data in some files and I'd really like to visualise the resulting structure. I hope that seeing it will allow me to optimise, not the code, but the data itself. I'm wondering if there is a debugger that will do this or perhaps a way I can d...

Override default behavior of TAB in JTextPane

I am implementing a JTextPane-based text editor. Currently, when I have a piece of selected text, pressing the TAB key deletes the selected text. I would like to change this behavior such that TAB will indent the selected text. How to go about it? ...

Closing Streams in Java

Hello, why do we need to close a FileInputStream (and streams in general) in any case before we leave the program? What would happen otherwise? If the program stops before the input stream is closed explicitly in the program, doesn't the stream also close automatically? Thank you. ...

What is the correct way to add a Shutdown Hook for an Eclipse RCP application?

I have an RCP application that uses a connection to a in-memory database. There is one circumstance that, when shutting down windows, the application is killed without giving it a chance to close the connection to the database. I researched a little and it seems that adding a Shutdown hook is the best way to detect this event and do cl...

Java for intermediate .NET Developer

I am a .NET Developer with about 5 years of web development experience using Microsoft technologies starting with classic ASP to ASP .NET 3.5. I do have a little background in Java as well and can write/understand Java code very easily. I am looking for resources (online, books) that are compatible with my .NET experience. I am only int...

In Java, is the "finally" block guaranteed to be called (in the main method)?

I'm a Java rookie and I was wondering, if I have the following typical Java code public class MyApp { public static void main(String[] args) { try { // do stuff } catch { // handle errors } finally { // clean up connections etc. } } } does the JVM guarantee that the finally block will always be ru...

Does Java 6 open a default port for JMX remote connections?

My specific question has to do with JMX as used in JDK 1.6: if I am running a Java process using JRE 1.6 with com.sun.management.jmxremote in the command line, does Java pick a default port for remote JMX connections? Backstory: I am currently trying to develop a procedure to give to a customer that will enable them to connect to on...

JBoss debugging in Eclipse

How do you configure JBoss to debug an application in Eclipse? ...

Java socket programming

Leading on from my previous questions I am going to try and clarify one of the problems I am facing. I am trying to create a multiplayer version of PacMan. A simple overview of how i've made my application is that I have a server which has a ServerSocket which is constantly listening on a specific port. Once a client connects it creat...

How to call a java method from a jsp when a html element is clicked?

As title says, how do I call a java class method from a jsp, when certain element is clicked (by example an anchor)? (Without reloading the page) If this can be done, how I pass the method, some part of the html code of the page that invokes it? Im using jsp, servlets, javascript, struts2 and java, over Jboss AS. ...

The use of "this" in Java

Hello, I have a question about the use of "this" in Java. If I write the following class: public class Example { int j; int k; public Example(int j, int k) { j = j; k = k; } public static void main(String[] args) { Example exm = new Example(1,2); System.out.p...

Database framework developing

Hello everyone, I'm developing (another) java web framework for personal use, and in addition to that I also want to develop somekind of persistence framework. I have already developed and engine that in order to access the table, you must only extend a class and create your fields with the same type and name of those in the table. Ex:...