java

Ready configurations for Spring + Hibernate

Sometimes, it's very tediously to make own configuration, find all libraries, check it ... So, is there any ready typical (template) config for appropriative task? ...

How can I create an instance of type dynamically in Java

Hello. In my Java application I have method public <T extends Transaction> boolean appendTransaction(T transaction) { ... } and inside of this method I need to create an instance of object T which extends Transaction Is it correct to do it in this way T newTransaction = (T) transaction.getClass().newInstance(); ...

Cloning iterators in Java

I have a LinkedList in Java, an iterator to browse the list and I would like to clone the iterator to do some temporary "look ahead" processing of the list with respect to the position of the original iterator. I understand that cloning an iterator is not possible in every situation, but is there a way to clone an iterator to a LinkedLi...

How to run shell script on remote machine from Java?

I'm creating a test which will perform some stress testing of the app which talks to a Postgres database. In order to make it replicable I'd like to recreate the database on every run. Startup method decorated with org.junit.Before annotation will drop the database (if it exists) and restore it from a dump file. Doing this form shell/com...

How can I convert HSSFWorkbook into a CSV file..?

I wish to convert HSSFWorkbook into a CSV file format and then write it to ServletOutputStream where I have setContentType as text/x-csv. Thanks in advance. ...

How to implement autoload in a Java application

So I'm writing this JFrame application that has its own document model that can be loaded and saved to a filepath. I'm wondering what good ways are there to make the application open the last saved file when it starts up. Do I store last saved document filepath in a proprietary way or is there some facility in java that can handle this ...

Get rid of client-config.wsdd in Axis

I am setting up my test environment and I need to programmatically register my handler/transport instead of using a client-config.wsdd: <?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"&gt; <handler name="MyClient" type="java:foo.bar.M...

Android color picker - updating color array

Hi all, I'm trying to create a color picker for Android that looks like a minimalistic version of Gimp's. So, it has a hue slider and a rectangle with saturation/value variants of a color chosen in hue slider. Question: what is the best way to create the rectangle? Right now, I'm creating an 200x200 array of pixels, but it takes ~5sec ...

How to merge subtree into parent tree in C#

Hello to All, I have some problem in my code regarding Tree, Actually i am reterieving presentation linkbase from database postgresql which is in this tree form: Revenue Global Services Hardware H1 H2 software global financing other other1 ...

cool debugging of object

I just had an idea that I wonder whether is possible in java. Let's say when doing debugging using eclipse or netbeans, you could record an object and save it. Then when going through the second round of debugging, save the object again. Now you could compare the first object recorded with the second object for all properties and find ou...

Hibernate mapping for situation, where the the key is also used as many-to-one parameter

I was wondering if there is a way to do Hibernate mapping for the following. My two days spent on this say there isn't. There are two tables, having one to many relationship. +---------------------+ +-----------------+ | versioned_entity | | basic_entity | +---------------------+ +-----------------+ | fk_BasicEn...

method overriding in Java

How is method overriding implemented in Java? In C++ we have the concept of vtable.. how is this implemented internally in Java? ...

How to create a package for different files?

How do I create a Java package for different files? I have tried the following. What have I done wrong? And what is the right procedure? The first file is: package dil; public class Hello { Support sp=new Support(); int i=sp.tin(); public void man() { System.out.println(i); } } The second file is: packag...

Mac L&F problems: Differing behavior of JTextField.requestFocus()

I have a problem with JTextField.requestFocus() behavior that appears to be different on Mac OS X. Here is my situation: I have a dialog with a JList and a JTextField. The user is supposed to write a boolean expression in the text field, and the list contains the names of all the variables that might be entered in the expression. Becau...

Java: Convert String object to Date object

How can I convert a String object to a Date object? I think I need to do something like this: Date d=(some conversion ) "String " Any help would be greatly appreciated. ...

LazyInitializationException while unit-testing Hibernate entity classes for use in Spring, using TestNG

Hi guys, In my Spring configuration, I've asked that the session should remain open in my views: <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"> <property name="sessionFactory" ref="sessionFactory"/> <property name="flushMode" value="0" /> </bean> ...

What do the different kinds of Eclipse Content-assist do?

In my Eclipse Preferences -> Java -> Editor -> Content Assist -> Advanced settings, I see the following: Java Non-Type Proposals Java Proposals Java Proposals (Task-focused) Java Type Proposals JPA Proposals (is always empty for me) PDE API Tools Proposals (gets skipped when checked in the Content-Assist Cycling settings) SWT Template ...

How to run CoMIRVA jar ?

I am new in java but I need to run CoMIRVA (http://www.cp.jku.at/people/schedl/Research/Development/CoMIRVA/webpage/CoMIRVA.html) I've download comirva-0.2.N3.jar and put the required libraries in the same folder. When I run the command "java -jar comirva-0.2.N3.jar" it gave me: "Exception in thread "main" java.lang.NoClassDefFoundError...

Java JList scroll to selected item

Hi, I have a jlist with a lot of items in it, of which one is selected. I would like to scroll to the selected item in this jlist, so the user can quickly see which item is selected. How can I do this? thanks! String[] data = {"one", "two", "three", "four", /* AND A LOT MORE */}; JList dataList = new JList(data); JScrollPane scrollPa...

Will this code be evaluated on every iteration?

I have this for-each-loop: for (Component c : container.getComponents()) { // Loop code } Is getComponents called on every iteration? Does it make sense to call getComponents before the look and only work on a cached array? ...