java

Database replication for redundancy using a free database and a Java with Spring & Hibernate web application

Hi, I have this in mind: On each server: (they all are set up identically) A free database like MySQL or PostgreSQL. Tomcat 6.x for hosting Servlet based Java applications Hibernate 3.x as the ORM tool Spring 2.5 for the business layer Wicket 1.3.2 for the presentation layer I place a load balancer in front of the servers and a rep...

Deleting non-empty directories in Java

Supposing I have a File f that represents a directory, then f.delete() will only delete the directory if it is empty. I've found a couple of examples online that use File.listFiles() or File.list() to get all the files in the directory and then recursively traverses the directory structure and delete all the files. However, since it's ...

Simple database-based instance synchronization

I'm working on a service that runs in a java app server farm that needs to do some periodic jobs (say, once every 2 minutes). The service must interface to external entities, and it is necessary to synchronize the different instances so that only one of them works on the job at a given time. Since the service uses a DB during this job,...

Document-Rendering in Java

I want to render MSWord, PDF, HTML, etc to an image (e.g. TIFF) from server-side Java. Most available products are shareware printer drivers, and so not suited to a commercial server app: I'd like the library which is robust, well-supported, performant, and concurrent. Any suggestions for open-source or commercial libraries? ...

What OSGi Container Do You Recommend ?

For the purposes of building a service framework that works quietly behind the scenes in the JVM, logically separated from whatever the primary application running is, it seems like OSGi really lends itself to this purpose. Some of my challenges are class loader segregation, versioning, "plugability" and.... what's the term?.... updateab...

Why doesn't the Java SDK installer set JAVA_HOME?

I always wondered why I have to manually set the JAVA_HOME environment variable after installing the Java SDK. JAVA_HOME=c:\Program Files\Java\jdk1.6.0_12 Visual Studio at least provides a batch file to set these kind of environment variables: call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" Does Java ha...

What is a best solution for hot deploy to Jetty?

Hi, I have a web application which is running on jetty. Continues builds are built on hudson. I would like to make a hot deploy on demand from hudson. I found cargo plugin which should be able to do so but cargo's web doesn't show any complete example how to do it - for remote jetty server - may be I miss it? What do you suggest? Do y...

How do I instantiate an Object that uses generics with Spring framwork?

I have a class that looks like this: class Dao<T>{ ... } I want to do this new Dao<Student>(); from the Spring XML configuration. Can that be done? How? ...

Is there a good command line argument processing API for Java?

Is there library support for parsing command line arguments in Java? Preferably in the APIs that are with the default JRE, and supporting UNIX-like arguments Something along the lines of PERL's GetOpt? ...

Bitwise AND, Bitwise Inclusive OR question, in Java

I've a few lines of code within a project, that I can't see the value of... buffer[i] = (currentByte & 0x7F) | (currentByte & 0x80); It reads the filebuffer from a file, stored as bytes, and then transfers then to buffer[i] as shown, but I can't understand what the overall purpose is, any ideas? Thanks ...

What is the easiest way for a Java application to receive incoming email?

Sending email is easy with commons-email, and with spring it is even easier. What about receiving incoming email? Are there easy to use APIs that allow to bounce emails, process attachments, etc. ...

RAR archives with java

Hello! Is there a good java API for manipulating RAR archive files someone could recommend? Googling did not turn up anything overwhelmingly convincing... Thanks alot! ...

Scalability and high availability of a Java standalone application

We are currently running a Java integration application on a Linux box. First an overview of the application. The Java application is a standalone application (not deployed on any JEE application server like OracleAS,WebLogic,JBOSS etc). By Stand Alone I mean its NOT a DESKTOP application. However it is run from the command line from a ...

display image in servlet

hi, I am having the following requirement. When the user cliock the buton the image should be displayed.The following code that i have tried gives me error Toolkit tk = Toolkit.getDefaultToolkit(); Image ima = Toolkit.getImage("C:\\DB.jpg"); MediaTracker mt = new MediaTracker(new Canvas()); mt.addImage(ima, 0); try ...

Relationship between JTable, TableModel & TableData

Whats the relationship between a JTable, TableModel and TableData. If i just modify the TableData, does that also change the data display on the JTable component or i have to call some method to sync the two. I have looked at this, but it does not explicitly tell or show me the relationship in terms of updates ...

Virtual Memory Usage from Java under Linux, too much memory used

I have a problem with a java application running under linux. When I launch the application, using the default maximum heap size (64mb), I see using the tops application that 240 MB of virtual Memory are allocated to the application. This creates some issues with some other software on the computer, which is relatively resource-limited...

What are the advantages and disadvantes of yaml vs xml for Object graph de/serialization?

The use case is long term serialization of complex object graphs in a textual format. ...

Java or scripting

What are the benefits of using Java to build web applications over scripting languages such as PHP ? ...

What is @Override for in Java?

Is there any other reason to annotate a method with @Override other than to have the compiler check that the superclass has that method? ...

How to find the line number of the start of a procedure in Eclipse

I have code that correctly finds the line number of an IMethod in Eclipse under Windows: IMethod method= ...; String source= type.getCompilationUnit().getSource(); int lineNumber= 1; for (int i= 0; i < method.getSourceRange().getOffset(); i++) if (source.charAt(i) == Character.LINE_SEPARATOR) lineNumber++; However, this doesn...