Is it necessary to parametrize the entire interface for this scenario, even though Bar is only being used in a single method?
public interface IFoo<T>{
void method1(Bar<T> bar);
//Many other methods that don't use Bar....
}
public class Foo1 implements IFoo<Yellow>{
void method1(Bar<Yellow> bar){...};
//Many othe...
I made the observation that my java application is running much faster when executed on an AMD processor in contrast to an Intel CPU.
For example my JBoss starts in about 30 seconds on a 3 GHz AMD processor and needs about 60 seconds on a 3 GHz Intel processor with identical disc, RAM and OS?
Has anyone else made this observation? Why ...
I have a friend who's just getting into .NET development after developing in Java for ages and, after looking at some of his code I notice that he's doing the following quite often:
IDictionary<string, MyClass> dictionary = new Dictionary<string, MyClass>();
He's declaring dictionary as the Interface rather than the Class. Typically I...
I have a number of one dimension arrays of Object[] (these objects are primitive types if it helps)
I want to store these arrays in a List, but only the arrays whose contents are unique from the rest.
My first aproximation was to iterate througth the arrays storing in a Set the value of Arrays.hashCode(array) and only storing the array...
JOptionPane.showMessageDialog is supposed to be a useful utility for getting user feedback as it blocks your current thread while you wait.
I would expect therefore that it would be thread-safe and that you wouldn't need to wrap the call in an invokeLater or an invokeAndWait.
Is this the case?
...
I'm trying to update the input of JFace TreeViwer periodically using setInput() method. Also I use the
viewer.setExpandedElements(expandedElements);
viewer.setExpandedTreePaths(expandedTreePaths);
methods to save the state of the tree. But after each setInput() call the TreeViewer flickers. How can avoid from flickering ?
...
In searching for an answer to an interesting situation which I had recently encountered I came upon the following question: Type safety, Java generics and querying
I have written the following class (cleaned up a bit)
public abstract class BaseDaoImpl<T extends Serializable> extends HibernateDaoSupport implements BaseDao<T> {
/**
...
I'm working on a project that uses JSObject from the jre's plugin.jar, which isn't included in the build path normally. I can get things to compile fine by adding the jar to the classpath. Currently I'm doing this in eclipse via Project->Configure Build Path->Libraries->Add External JARs... -> find the jar in jdk/jre/lib/plugin.jar. T...
Is there a tool/library that allows me to import the java packages automatically outside the IDE?
For instrance if I type in notepad something like:
JFrame f = new JFrame();
Then run this magic tool, and then have automatically written as:
import javax.swing.JFrame
....
JFrame f = new JFrame();
Is there something like that?...
I am getting the following error on execution of a multi-threading program
java.lang.OutOfMemoryError: Java heap space
The above error occured in one of the threads.
Upto my knowledge, Heap space is occupied by instance variables only. If this is correct, then why this error occurred after running fine for sometime as space for inst...
I have made a multi-threading program. In it, the main thread starts 10 threads but the problem is whenever an exception occured in one of the threads, the whole application gets stopped.
But I want that whenever an exception occurred in one thread, only that thread should gets stopped and other threads keep working. How can I do that?...
When I create a JPanel in Netbeans, it allows me to specify which LayoutManager to use for it from a fixed set of LayoutManagers, including BoxLayout. After adding a couple of components to the JPanel, I would like to add horizontal spacers (created using Box.createHorizontalStrut) to make the layout look better. I could manually add the...
I'm having trouble using Sun's PDF Renderer package to view PDFs with embedded fonts. I have the following code which creates a BufferedImage out of every page of a PDF for viewing in my application, and it works fine when there are no embedded fonts. However, when the PDF has embedded fonts, it shows no text. Any ideas? Also, it ope...
Hi,
I got a module which RSA encrypts the data and passes on to the C#.
C# needs to decrypt it based on the public key (64 bit encoded) and the passed token.
I have token , 64 bit encoded public key, can some help me get with the sample to get started.
All I know from Java end is, it is using. I have got the result from Java end and nee...
I want to find memory leaks in my java application but I don't know how to use Netbeans profiler to do that.
...
I know about using Runtime.exec, you pass it a native program to run + arguments. If it's a regular program, you can run it directly. If it's a shell script, you have to run an external shell program like sh or csh or cmd.exe.
Is there some Java class (either standard or open-source) that implements a shell, meaning a program that you p...
It is necessary to disconnect from the database after the job is done in Java? If it is not disconnected, will it lead to memory leaks?
...
This is probably an easy question for anyone with any moderate expertise with web services using Apache Axis.
I have a web service client that was generated by wsdl2java in Axis 1.4. I am writing unit tests that need to access the actual SOAP message itself, and do a comparison to the client side java classes which are generated by Axis...
I have an XML file which I need to parse using PHP and send the parsed data to Java, what are some best practices to accomplish it ?
...
So, I realize the answer to this is probably "it's hard", but:
I've got a weird idea, and was wondering if it's possible in Java to create a method like:
<T> T wrapInterface (Class<T> interfaceClass, T wrappedObject) {
if (mClass.isInterface()) {
//create a new implementation of interfaceClass that, in each method,
//does so...