java

Extending Java Web Applications with plugins

I have this web application that has grown to an unmanageable mess. I want to split it into a common "framework" part (that still includes web stuff like pages and images) and several modules that add extra functionality and screens. I want this refactoring to also be useful as a plugin system for third-party extensions. All modules n...

Generic Java Framework to Manage Bidirectional Associations and Inverse Updates

Hello, I've been looking for a generic way to deal with bidirectional associations and a way to handle the inverse updates in manual written Java code. For those who don't know what I'm talking about, here is an example. Below it are my current results of (unsatisfying) solutions. public class A { public B getB(); public void ...

Bad Gateway 502 error with Apache mod_proxy and Tomcat

We're running a web app on Tomcat 6 and Apache mod_proxy 2.2.3. Seeing a lot of 502 errors like this: Bad Gateway! The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /the/page.do. Reason: Error reading from remote server If you think this is a ser...

Open source Java library to produce webpage thumbnails server-side

I am searching for an open source Java library to generate thumbnails for a given URL. I need to bundle this capability, rather than call out to external services, such as Amazon or websnapr. http://www.webrenderer.com/ was mentioned in this post: Server generated web screenshots, but it is a commercial solution. I'm hoping for a Java...

Is there a way to implement algebraic types in Java?

Is it possible, in Java, to enforce that a class have a specific set of subclasses and no others? For example: public abstract class A {} public final class B extends A {} public final class C extends A {} public final class D extends A {} Can I somehow enforce that no other subclasses of A can ever be created? ...

How do I dynamically add Panels to other panels at runtime in Java?

I'm trying to get into java again (it's been a few years). I never really did any GUI coding in java. I've been using Netbeans to get started with this. When using winforms in C# at work I use a usercontrols to build parts of my UI and add them to forms dynamically. Ive been trying to use JPanels like usercontrols in C#. I created a J...

Graph Problem: Help find the distance between the two most widely separated nodes.

I'm working through previous years ACM Programming Competition problems trying to get better at solving Graph problems. The one I'm working on now is I'm given an arbitrary number of undirected graph nodes, their neighbors and the distances for the edges connecting the nodes. What I NEED is the distance between the two farthest nodes...

Java - Common Gotchas

In the same spirit of other platforms, it seemed logical to follow up with this question: What are common non-obvious mistakes in Java? Things that seem like they ought to work, but don't. I won't give guidelines as to how to structure answers, or what's "too easy" to be considered a gotcha, since that's what the voting is for. See als...

Minimal Java web app struture / ant build file

Hello, Can some describe the minimal conventional directory structure for a Java web app, and the minimal build.xml to get ant to build it, and make a war? Target for today is deploy a Wicket app to Tomcat outside of an IDE, just with ant and my favourite text editor. ...

What features would you like to see in Java?

This is a pretty unoriginal question! Where do you stand on the Closures Proposal? What else would you want to see? For me it has to be a new decimal type which is really a BigDecimal but allows for standard math operations using +, -, x, / etc. ...

Java: Save objects in a textfile? Are there readymade solutions?

Hello, I want to save the objects I generated in a program. After restart the App should load automaticly all Objects in an Array. I want to write them in a file and parse them after restart. Are the other smarter possibilities than do it by hand? Thank you ...

What do you think of the direction C# is heading for compared to Java?

C# 3/3.5 includes a set of new features which Java does not support (linq, wwf, lambda expressions, etc). C# 1.0,1.1 and 2.0 was comparable to Java in many ways. What do you think of this? do you agree? Is this a good thing? What is the future for both these languages compared to each other? ...

UNIX socket implementation for Java?

I realize that since UNIX sockets are platform-specific, there has to be some non-Java code involved. Specifically, we're interested in using JDBC to connect to a MySQL instance which only has UNIX domain sockets enabled. It doesn't look like this is supported, but from what I've read it should be at least possible to write a SocketF...

Eclipse plugin manifest problem - empty package inconsistency between mac and PC

I am developing a collection of plugins on Eclipse 3.4 (official) on both mac and a PC. At present (I'm aware it is not the best practice) some of my common plugins export all of their packages. The problem is this: many of the listed packages are empty because subpackages are not, for example: prefix.core may be empty while prefix.co...

How do you design a good permgen space string in Java?

I'm wondering how you would go about designing a good permgen space string in Java. Based on my research and understanding I've come up with the following: example: JAVA_OPTS='-Xmx512m -XX:MaxPermSize=256m -server - Djava.awt.headless=true' sorry the example didn't paste when I first posted the question...... ...

Emulating user input for java.util.Scanner

I'm writing a game in Java, and I want the user to be able to provide input from both the command line and my GUI. Currently, I use this method to get input: static String getInput(){ System.out.println("Your move:"); Scanner sc = new Scanner(System.in); return sc.nextLine(); } I want to keep using this...

How do I change the "level" of validation that Ant's XMLValidate task provides?

I am attempting to use Ant's XMLValidate task to validate an XML document against a DTD. The problem is not that it doesn't work, but that it works too well. My DTD contains an xref element with an "@linkend" attribute of type IDREF. Most of these reference IDs outside of the current document. Because of this, my build fails, since t...

Autostart spring app

So is there a way to initialize and start a command line Spring app without writing a main method. It seems like all such main methods have the same form public static void main(final String[] args) throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class); FooService fooService = ...

Java maximum memory on Windows XP

I've always been able to allocate 1400 megabytes for Java SE running on 32-bit Windows XP (Java 1.4, 1.5 and 1.6). java -Xmx1400m ... Today I tried the same option on a new Windows XP machine using Java 1.5_16 and 1.6.0_07 and got the error: Error occurred during initialization of VM Could not reserve enough space for object heap Cou...

Using Java-classes with C#

I have a project written in Java (>1.5). Is it possible to write parts of the project with C#? For instance the GUI and calling the methods and instanciate the classes written in java? If yes, how? ...