java

How do I use an equivalent to C++ reference parameters in Java?

Suppose I have this in C++: void test(int &i, int &j) { ++i; ++j; } The values are altered inside the function and then used outside. How could I write a code that does the same in Java? I imagine I could return a class that encapsulates both values, but that seems really cumbersome. ...

jar resources in jnlp are not signed by the same certificate

I've been working with web start for a couple years now and have experience with signing the jars and what not. I am taking my first attempt at deploying a RCP app with web start and though I have in fact signed all of the jars with the same certificate I keep getting this error: 'jar resources in jnlp are not signed by the same certific...

Apache Ant + Ivy build of a web application which is deployed to a local Tomcat

Hi, I will use Apache Ant and Apache Ivy to build a web application which is deployed to a local Tomcat instance (during development). I have some questions: I want to grab most of my dependencies from the Maven2 repositories which works fine, but for the servlet JAR I would like to use the one Tomcat provides. Is there a way to do th...

StaleObjectStateException ERROR - please help

Hi, Anyone can point me to the error please? Note: this is a simplified test case extracted from my real app. Thus the weird usage of 3 entity managers and em1.getTransaction().begin(); em1.clear(); em1.close(); at the end of each section. In real app it happens in different times. HibernateUtil is basically copied from the tutorial. ...

Eclipse plugin for Apache Axis2 to create webservice

hi, please give me the link to download plugins for apache axis, i tried in some sites but the link was not current so i was not able to download. thanks in advance, Mahesh ...

How to make full screen java applets?

Hello to all, I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this. Since I haven't been using java applets for 3 years(The last time I've used it was for a course homework :) ) I have forgotten most of the concepts. I googled and...

Spring context files organization and best practices

We have started using Spring framework in my project. After becoming acquainted with the basic features (IoC) we have started using spring aop and spring security as well. The problem is that we now have more than 8 different context files and I feel we didn't give enough thought for the organization of those files and their roles. New ...

How do I identify language of a text document in Java?

Is there an existing Java library that could tell me whether a String contains English language text or not (e.g. I need to be able to distinguish French or Italian text -- the function needs to return false for French and Italian, and true for English)? ...

Appending to XML with XMLStreamWriter

Basically the app writes the contents of a Collection to XML. I'm using XMLStreamWriter (XMLOutputFactory.newInstance().createXMLStreamWriter(...)) for this purpose. Works great except for the fact that I can't get how to append data to an existing file. Don't really like the idea of reading all of it first, appending the data in memory...

Can you define your own template variables in Eclipse

In Eclipse there are templates that help you by automatically inserting some code or comments. You can edit these templates yourself via Preferences > Java > Editor > Templates. There are so-called "template variables" that you can use to make these templates a little smarter. For instance, there is the ${see_to_overridden} variable tha...

Alternative document structure in JTextPane?

In a JTextPane with a DefaultStyledDocument the document structure (hierarchy of Element objects) ends with a LeafElement that spans all the character of the enclosing paragraph. Is there a way to customize the document such that each leaf element will represent a single character? (Background: I am trying to implementing a custom color...

Wiki rendering in GWT

Client side rendering is useful when we want to use wiki like syntax. Unfortunately I have not found any library which gives wiki syntax rendering in GWT client side. Does anyone knows such an API/library? ...

Swing components inside HTML

Does anybody know of a pure java (ar at least cross platform) open source component/library which displays HTML which can contain swing components inside it? All I could find were either abandoned or incomplete. I am asking because I'm thinking about trying out approach to do use this combination for creating desktop application. EDIT...

Grails, Inserting lots of data using withTransaction results in OutOfMemoryError

I'm using Grails 1.1 beta2. I need to import a large amount of data into my Grails application. If I repeatedly instantiate a grails domain class and then save it, the performance is unacceptably slow. Take for example importing people from a phone book: for (each person in legacy phone book) { // Construct new Grails domain class f...

Disabling seam's redirect filter

I'm doing a project in seam that requires restful URLs. I have a view that is mapped to /group/{group}/{locale}. On that page I have a list of so called messages. Each message has a button to save changes to the message. This is linked to an action bean like this: <h:commandButton type="submit" value="Save Changes" action="#{groupAction...

"Group Box" in Java Swing

Trying to build a GUI application in Java/Swing. I'm mainly used to "painting" GUIs on the Windows side with tools like VB (or to be more precise Gupta SQLWindows .. wonder how many people know what that is ;-)). I can't find an equivalent of a Group Box in Swing .. With a goup box, you have a square box (usually with a title) around...

VisualEditor in Java - dynamically build sub-panel?

I'm using the "Visual Editor" to "paint" my Swing GUI. Can I dynamically build the contents of a sub-panel with VE or do I have to use a predefined sub-class of JPanel (and build that with VE)? ...

iText copy form fields

Is there a way in iText to copy just the PDF acroform fields from one PDF document to another PDF document? I have the code to copy the entire PDF, but I would like to be able to overlay all my fields to a new/updated PDF document. ...

Is there a way to pass a Number as a parameter in Java?

I'm allocating an array of T, T extends Number inside a class. I can do it this way: myClass test = new myClass(Double.class, 20); Then the constructor itself: myClass(Class<T> type, size) { array = (T[]) Array.newInstance(type, size); } I'd like to know if it's possible to do it like this: myClass(Number n, size) { array ...

Do you use design marker interfaces to document your Java code?

I just stumbled upon this article by Bruce Wallace: Design Markers - Explicit Programming for the rest of us Bruce describes a way to use interfaces to explicitly document things about your classes that can't otherwise be enforced in code. Bruce's example: Immutable classes Suppose you have a class that should be immutable. There is...