Say, You have an application which lists down users in your application. Ideally, if you were writing code to achieve this in Java, irrespective of what your UI layer is, I would think that you would write code which retrieves result set from the database and maps it to your application object. So, in this scenario, you are looking at yo...
I would like to test Spring configuration in Junit test case without invoking init-method on configured beans. I could of coded my init-methods to skip actual work based on system property which could of been set in test case but I am looking for a cleaner solution.
...
What is the simplest way to find if two Lists contain exactly the same elements, in the standard Java libraries?
It shouldn't matter if the two Lists are the same instance or not, and it shouldn't matter if the type parameter of the Lists are different.
e.g.
List list1
List<String> list2;
// ... construct etc
list1.add("A");
list2....
A few years ago, I did a survey of DbC packages for Java, and I wasn't wholly satisfied with any of them. Unfortunately I didn't keep good notes on my findings, and I assume things have changed. Would anybody care to compare and contrast different DbC packages for Java?
...
Hi to all!
I need to execute a JSP. But I need to directly from Java, without using Tomcat or any other servlet container. Compiling JSPs would be a good thing too, but not necessary. I think maybe org.apache.jasper package is good for doing this, but I can't find any good example or tutorial online.
I need something as:
Class compil...
In Java, is there any way to get(catch) all exceptions instead of catch the exception individually?
...
My first attempt at jython is a java/jython project I'm writing in eclipse with pydev.
I created a java project and then made it a pydev project by the RightClick project >> pydev >> set as... you get the idea. I then added two source folders, one for java and one for jython, and each source folder has a package. And I set each folder a...
My Java is rusty so please bear with me. In C I can do:
int someFunc(void)
{
printf("I'm in %s\n", __func__);
}
In Java, can I lexically get to the name or class of the type currently being defined. For example, if I have:
import org.apache.log4j.Logger;
class myClass {
private static final Logger logger = Logger.getLogger(m...
I would like to implement a socket server that will be connected to by multiple clients. In order to make the implementation as simple as possible and not have to code management of threads and connections etc I'd like to use Tomcat. We already use tomcat as part of our solution.
I am sure that Tomcat can be used for non http servlets a...
Hi,
How could I add to a plot an OHLCSeriesCollection and a TimeSeriesCollection , in order to represent their values in the same chart ?
...
if I have a code which has the clone() method but as I know that the duplicate code is bad here(in that application e.g.bank Application),what should I do???
the clone() method is in the bankOfAmerica which implements IAccount(IAccount has the clone() method header!)One person has override the clone() method in the bankOfAmerica class an...
Is there any way in Java that a statement like
Thing thing = new Thing();
could not result in a new object being created (i.e. any way that thing could end up pointing to an already-existing object)?
...
Hi all,
I have recently found a bug that causes a NullPointerException. The exception is caught and logged using a standard slf4j statement. Abridged code below:
for(Action action : actions.getActions()) {
try {
context = action.execute(context);
} catch (Exception e) {
logger.error("...", e);
break;
...
In Java how do I get a JList with alternating colors? Any sample code?
...
I'm having trouble with memory in a j2me application. (see another question)
I discovered that one class has a loop that doesn't stop until the application is closed. This loop is consuming all the memory available.
I didn't make this class so I don't know why things was done this way. So any suggestions are welcome.
Here is a simplif...
In Java, of course. I need to enable "force", but I have no idea how. I'm sure it might go somewhere in the URL, but I've tried a bunch of different things and looked for a bit on Google, to no avail.
Thanks!
...
I am working on a jsp page which uses a bean to create an OAuth authenticated HttpURLConnection and am able to connect successfully. Is there anyway that I can take that open HttpURLConnection and somehow display the contents in a browser window?
...
Hi ,
There is 2 jComboBox .. and 2 Class . When form load event it will fill jComboBox1,when ActionEvent fired it will load another class with selection of the jComboBox1.I wanna get PersonelID from jComboBox.GetSelectItem method than call another class with this id. But gettin this error ;
Exception in thread "AWT-EventQueue-0" javax....
I have a database table using an enum. This is already working with hibernate (using XML), and I'm trying to convert it to annotations as this is one of the last pieces to still be using xml notation.
The column definition:
enum('Active','Pending','Cancelled','Suspend')
The following works:
<property
name="status"
column="S...
Am I correct in assuming that if you have an object that is contained inside a Java Set<> (or as a key in a Map<> for that matter), any fields that are used to determine identity or relation (via hashCode(), equals(), compareTo() etc.) cannot be changed without causing unspecified behavior for operations on the collection? (edit: as allu...