java

How do you implement Basecamp style URL in Java/JEE environment? eg <username>.hostname.com

The Basecamp URL like .basecamphq.com, eg seymores.basecamp.com. How can I do the same in Tomcat environment? ...

In Java, is there a way to obtain the component where an event is being handled?

Suppose I have 4 squares colored blue, white, red and green (myComponent) associated with the mouse press event. At one point, the mouse is pressed over one of them - say, the yellow one - and the event is activated. Now, the control flux is inside the event handling function. How do I get the MyComponent - the yellow square - that caus...

Using 3d transformation matrices

In an AI class we have a robot that has an arm with 7 joints. Each joint can rotate a different direction. I need to know where the very end is going to be. I've been trying to do 3d matrix multiplication and it works for one joint but once I add in another it doesn't line up with a model I made using the Java3D api. This is how I'm ...

Apache Derby - Check Database Already Created?

Hey, Using Apache Derby with Java (J2ME, but I don't think that makes a difference) is there any way of checking if a database already exists and contains a table? Cheers, Pete ...

What is the preferred way to do site templates and themes with Wicket?

I'm just learning Wicket, and Googling yields different results about how to theme/template a site using Wicket. It appears that the common methods are: Markup Inheritance (description) Borders (description) Reusable Panels (description) Fragments (description) What is the best practices / "right" way to do this in Wicket? Or do the...

Generics and Collections in GWT, Null Pointer

When calling a method that adds an object to a collection in GWT I get a null pointer error. I have no idea why as everything I have done creates a very simple object (only contains a string). Here is the code that calls the function and the function: public class PlantMenu extends VerticalPanel { private Collection<PlantData> pl...

Easy way to find Subtree in a Tree

I'm writing some code that uses a Tree (a regular tree that can have an unlimited number of nodes, but no crossover, i.e. two parent nodes will not point the the same child node). Anyway, two things: 1) Are there any well-known algorithms for finding a sub-tree within a tree. 2) Are there any Java libraries (or any libraries for that ...

How To Configure Query Cacheing in EclipseLink

I have a collection of states, that I want to cache for the life of the application, preferably after it is called for the first time. I'm using EclipseLink as my persistence provider. In my EJB3 entity I have the following code: @Cache @NamedQueries({ @NamedQuery( name = "State.findAll", query = "SELECT s FROM State...

How do I configure Struts 2 with Tomcat 6?

Can anyone help me to configure struts 2.0.14 (I'm using tomcat 6.0). I want to know what is the procedure to build my first application in struts. Also tell me how xml is used to build a struts application. I have tried and tired of Google and that's why I'm here. Please suggest me some nice tutorial for struts out of your own experienc...

Why ‘No database selected’ SQLException?

why this program is not executing when it goes in to the do while loop second time and why it is giving the exception "Exception java.sql.SQLException: [MySQL][ODBC 5.1 Driver][mysqld-5.0.51a-community-nt]No database selected" //import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Result...

static methods make Java a pseudo functional language?

I've been mulling about a post by Misko Hevery that static methods in Java are a death to testability. I don't want to discuss the testability issue but more on the concept of static methods. Why do people hate it so much? It's true that we don't have closures (but we have a slightly awkward anonymous functions), lambdas & functions as ...

User Interface Design Tool

I'm searching for a User Interface Design tool to visualize a possible GUI in a documentation. I must not generate code. I know that Microsoft Visio provides a functionality. But are there any alternatives? Which software do you use for visualizing a GUI? Thank you in advance. Best regards from Switzerland Thomas PS. Another well-know...

Access by one client at a time

My requirements are as follows. I have a web application developed in java. I have a link in the html page. When the first client clicks submit button in the html page the batch file should run. Meanwhile when the other client clicks the submit button he should get message that the page is busy. If the first client clicks release but...

Which would make a Class file bigger? import java.awt.*, or a bunch or single import statements?

Okay, so if I had a project that used: import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Dimension; import java.awt.Font; import java.awt.Color; import java.awt.Polygon; Would it make the Class file smaller to use: import java.awt.* I'm thinking against it because I'm importing a lot of things I don't need. I'm ...

is there a way to share a single variable by all servlet classes in java

hi, i need to know whether there is a way to change the value of a single variable by two servlet classes. in one servlet i need to make a variable =true and in another servlet i need to make the variable =false ...

How to search for all methods in a project that return implementation of Collection interface?

I've been reading Josh Bloch's 'Effective Java 2nd Edition'. Item 43 states 'Return empty arrays or collections, not nulls'. My question is how can I search for all methods in a project that return an implementation of java.util.Collection interface? IDE that is used is Eclipse, but any way of finding the right result is acceptable, e.g....

Java newbie: Swing and displaying ASCII files

G'day all, I have an application which needs to display an ASCII file of 15 lines in a Swing component that cannot be edited by the user. Below is my code which reads the ASCII file byte by byte. My thanks to the helpful commenters who explained that a JTextArea.setEditable(false) would be appropriate in Swing. However, my code mer...

EJB3 and manual hierarchy persistence.

I have a legacy database, which I am using EJB3 to model. The database is in quite a poor shape, and we have certain unusual restrictions on how we insert into the DB. Now I want to model the database in a hierarchy that fits in with the DB strucuture, but I want to be able to manually insert each entity individually without the persiste...

What is the best way to find the users home directory in Java?

The difficulty is that it should be cross platform. Windows 2000, XP, Vista, OSX, Linux, other unix variants. I am looking for a snippet of code that can accomplish this for all platforms, and a way to detect the platform. Now, you should be aware of bug 4787931 that user.home does not work correctly, so please do not provide me of texb...

Java native array lengths

Hi, I have a 2D array of doubles in Java which is basically a table of values and I want to find out how many rows it has... It is declared elsewhere (and allocated) like this: double[][] table; then passed to a function... private void doSomething(double[][] table) { } In my function I want to know the length of each dimension w...