java

Can I set a window in Java so it has uniform resizing (ie. a square)?

I've seen several applications window's only allow the user to resize it in the diagonal direction, so it must maintain its square shape. Is it possible to specify this constrain using swing/java? ...

Java OO Questions

1) If i define a java method: void ChangeObject (Object o) { o = new Object(); } And in my main program, i instantiate an object o and call ChangeObject with o passed in. Will o remain intact after this method is run? 2) If i have two class: Child and Parent. And child is a subclass of parent. Which of these two statements will comp...

Generic logging of all calls to an EJB (2.1)?

I'm working on modifying an existing application implemented as a 2.1 stateless EJB. I'd like to put in some kind of generic, detailed, logging of all calls made to the EJB. Stuff I'd like to log: Name of method being called Serialized copy of all passed parameters Serialized copy of return value I implemented something like that fo...

Java+Eclipse: how do you debug a java program that is receiving piped/redirected stdin?

I'm using Eclipse to develop a Java program, and figured I'd add an option to my program to parse stdin if there are no arguments. (otherwise it parses a file) I am having problems if I execute "somecommand | java -jar myjar.jar" and went to debug... then realized I don't know how to start a process in Eclipse like that. And if I run it...

How do I get subset of a Java XML org.w3c.dom.Document ?

I have a XML org.w3c.dom.Document object. It looks sorta like this: <A> <B> <C/> <D/> <E/> <F/> </B> <G> <H/> <H/> <J/> </G> </A> How can I convert the Document object so that it strips off the root node and returns another Document object subset (selected by name) that looks like th...

Lucene crawler (it needs to build lucene index)

Hi, I am looking for Apache Lucene web crawler written in java if possible or in any other language. The crawler must use lucene and create a valid lucene index and document files, so this is the reason why nutch is eliminated for example... Does anybody know does such a web crawler exist and can If answer is yes where I can find it. T...

How do I set the Java path in Eclipse so I can run it on an external drive?

I have Eclipse 3.5.1 and Java Portable (from Portableapps.com) installed on a portable hard drive and would like to point my Eclipse to use the portable apps Java version. This will allow me to use Eclipse on a computer even if Java isn't installed. How do I accomplish this? ...

5 ways to use the static keyword in Java

I just had an interview where one of the questions was something like "Describe 5 ways to use the static keyword in Java." I could only think of 2 on the spot, and afterwards I found 2 more. What is the 5th? Declaring a field belonging to a class as opposed to an instance of the class. Declaring a method that can be called on a class...

Proper notation using doubles

It is more stylistically acceptable in java to write constants in double operations with or without ".0" ? As in, double var= 200.0; double d= var/250.0; double h= 1.0 - d; vs. double var= 200; double d= var/250; double h= 1 - d; Thanks ...

Launch options to force Java socket connections to localhost?

Hello, I'm trying to find a way to force any connection attempts a Jar makes to an external IP through my proxy server, which is running on localhost(Also a Java application). Once the proxy server receives the connection it will open a connection with the external IP and begin routing the IO to and from the client/server. I've been Goo...

JAXB to unmarshall <string>foobar</string>

Greetings! I have a server returning XML content to my client that looks like this: <string xmlns="...">foobar</string> I'm new to JAXB and have gotten a lot of stuff working, except this. I thought it would be pretty easy to marshal and unmarshal this to and from a String. It took a while, but I finally figured out how to marshal thi...

Why can I access my private variables of the "other" object directly, in my equals(Object o) method

In Java in the equals(Object o) method I can access the private variables of the passed in object without going through its public getters. public boolean equals(Object o){ ... MyObject other = (MyObject)o; return getProp() == other.prop; } How's that? ...

Eclipse cannot find java file generated via jsp on the work folder

I am currently programming using Eclipse 3.4.1 and using the Apache 5.5 as backend server. I am also using the com.sysdeo.eclipse.tomcat_3.2.1 plugin for tomcat. I was just wondering, when I encounter an error and prints the stack trace for the exception. I always would see the line code where the error occured on the java work file gen...

Transactional File Access and Caching in JBoss AS 5

We need to locally store a cache on a File System through JBoss 5. The files we need to store are big (~50 Mbyte) and there are many consumer (through WS on JBoss) that read these files and one producer (JBoss Biz Logic) that creates the last one. Because there are concurrent read and write problems, I would like to know if there is a ...

Is this a right way to put Java generics in action?

I just started messing with generics and I want to make sure I got this right, any help? public interface Cart<T extends CartItem> { public void setItems(List<T> items); public List<T> getItems(); } public interface CartItem { public BigDecimal getQty(); public void setQty(BigDecimal qty); // more } public class Ca...

Why throwing an EJBException is a "recommended" practice?

I keep getting this "suggestion" from many fellow developers over and over again. In my experience I've found that EJBExceptions are well-suited for "end of the world" from the bean instance perspective (like when something is so wrong that the bean instance cannot recover by itself). If an instance can recover, I think it's better to th...

How to "copy" a JMS message to 2 destinations?

I have a requirement that a single JMS message sent by a client must be delivered reliably (exactly-once) to two systems. These 2 systems are not HA-enabled, so the best suggestion that I came up with is to: create single queue where client posts to set up two "intermediate" queues use a custom "DuplicatorMDB" that will read messages f...

How to apply a patch

I have this patch code which i downloaded from a web article (Calling Matlab from Java). http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html But I donot know how to apply it in my windowsXp running computer. What I'm trying to do is call Matlab script file from java. I have found the necessary source codes and every thing but...

Loading Spring Context Dynamically at Run-time in a Web Application.

Hello Everyone, I'm converting a standard Java Application that uses Spring Framework into a Web App. This application loads new Spring Context based on run-time parameters, that was done using ClassPathXmlApplicationContext/FileSystemXmlApplicationContext. So my question is how to do the same in a Web Application given that I already...

How can I use lambdaj in my application

Hi there, This may sound like a stupid question, but how can I start to use lambdaj library? I downloaded the lambdaj.jar and put it in the lib directory in my webapp together with other jar files. But I can't import any of the classes. Do I need to build the jar using maven? Thanks in advance! David ...