java

Is there something like JET (Java Emitter Templates) but without Eclipse-dependencies?

Hello! I wanted to use JET (Java Emitter Templates) in my Netbeans projects, but had to find out that JET heavily depends on Eclipse libraries. Is there something similar to JET, but as a standalone project? Something which is open source and well maintained? Futhermore, is "code generation" the common term for such tools? I didn't fi...

How to strip whitespace-only text nodes from a DOM before serialization?

I have some Java (5.0) code that constructs a DOM from various (cached) data sources, then removes certain element nodes that are not required, then serializes the result into an XML string using: // Serialize DOM back into a string Writer out = new StringWriter(); Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.s...

Footer row in a JTable

What is the best way to put a footer row into a JTable? Does anyone have any sample code to do this? The only approach I've thought of so far is to put a special row into the table model that always get sorted to the bottom. Here is what I ended up with: JTable mainTable = new JTable(mainTableModel); JTable footerTable = new JTable(...

How do I migrate ejb2 stateless session beans to ejb3 piecemeal?

The EJB3 spec indicates that EJB2 and EJB3 can co-exist in a single application. I wish to migrate my EJB2 stateless session beans to EJB3 stateless session beans. This question does not relate to JPA at all (that is a separate piece of work to be carried out in the future) I'm running on websphere 6.1 with the EJB3 feature pack instal...

Any reason to clean up unused imports in Java, other than reducing clutter?

Is there any good reason to avoid unused import statements in Java? As I understand it, they are there for the compiler, so lots of unused imports won't have any impacts on the compiled code. Is it just to reduce clutter and to avoid naming conflicts down the line? (I ask because Eclipse gives a warning about unused imports, which is ...

Immutable Objects in Java and Accessing Data

I've implemented a class in Java which, internally, stores a List. I want the class to be immutable. However, I need to perform operations on the internal data which don't make sense in the context of the class. Hence, I have another class which defines a set of algorithms. Here is a simplified example: Wrapper.java import java.uti...

Any reason NOT to slap the 'synchronized' keyword everywhere?

In my java project, almost every non-static method I've written is synchronized. I've decided to fix up some code today, by removing most of the synchronized keywords. Right there I created several threading issues that took quite a while to fix, with no increase in performance. In the end I reverted everything. I don't see anyone else ...

How to export large data to excel across some 25 sheets in a single work book using java without Outofmemory exception?

Hello, I have a problem with Swing GUI which automatically closes when we run export to excel operation with more than one time continuously. The operation consists some 25 tabs data and each tab is having a table with more than 1k rows.This is a JNLP based application with 1024 mb RAM specified in the configuration file. Thanks in adv...

Auto startup for java desktop application?

Hi friends, I have created a desktop application in java using NETBeans IDE 6.1... and made a jar file of the application. Now I want to make its auto start up in such a way that its start up whenever client machine is booted. Thanks in advance Balwant ...

Find out Last 30 Days, 60 Days and 90 Days in java

Hi, How to get last 30 / 60 / 90 days records from given date in java? I have some records with receivedDate. I want to fetch the records for last 30 or 60 or 90 days from received Date. How to resolve it? Thanks in advance Gnaniyar Zubair ...

Eclipse and clip board

In Eclipse is there a provision to copy multiple items and then paste the items selectively from the clip board? IntelliJ has this feature and I used to find it very useful. Does Eclipse have this and if so what is the key board short cut to view items in the clip board? ...

How to make installer of java desktop application for multi-platform?

Hi friends, How could we made a jar file's installer, which can run on multi-platform, is there any simple way, because I don't know Java too well. Balwant ...

How can I debug AMF (BlazeDS) serialization of Java objects to Actionscript?

I'm using BlazeDS to remote some Java objects that I'm consuming in a Flex application. I'm getting a type coercion error with one of my classes that I can't for the life of me figure out. I have other classes that are working fine using the same data types, and I've gone over my mapping a dozen times. I'm following all of the necessa...

Java repaint not working correctly

i use the java repaint method , it repaints, but the update is only seen when I either click on the canvas or resize the panel. How can I fix this ? What causes it? ...

Why doesn't interceptor's onLoad() work?

We have a jboss based system persistance.xml looks like a following: <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/p...

Converting Swing application to JavaFX

What are necessary steps for converting Swing application to JavaFX? It would be interesting to know also about best practices for performing such task (i.e. problems that can be encountered and resolutions). ...

Making a redistributable component or library for Android

Hi Folks, I'm just starting out on Android and Java programming, coming in from a C++ background. I was wondering - whats the best way to go about making a library/UI widget/component that I can license to third-party developers? In C++ I'd ship the customers my headers and *.a files, but I don't know the equivalent in Java. Are ther...

C++ References and Java References

//C++ Example #include <iostream> using namespace std; int doHello (std::string&); int main() { std::string str1 = "perry"; cout << "String=" << str1 << endl; doHello(str1); cout << "String=" << str1 << endl; // prints pieterson return 0; } int doHello(std::string& str){ str = "pieterson"; cout << "String="...

UI for a Desktop App

I have a desktop application . The functionality is complete, but user interface requires a lot of work. I am looking for UI tools.My current operating system is Windows and application is required to run on both Windows and Linux. Can you guys recommend any? The software is customized file management application for a specific client,...

How Java Thread Class Determines Which thread?

While Going through the java tutorial on sun site, I see following piece of code: for (int i = 0; i < inputs.length; i++) { heavyCrunch(inputs[i]); if (Thread.interrupted()) { //We've been interrupted: no more crunching. return; } } Since Thread.interrupted() is a static function, how does java knows which ...