java

Visual inheritance in Java

The team in which I work has been getting problems with the visual inheritance of the forms in the Java platform. We want to develop a base JFrame with some controls in it and to have inherited forms from that base JFrame. The designer of the Netbeans 6.1 does not paint the controls of the base form in the inherited ones, so we can´t us...

hibernate auto-discovery and generation of of database mappings to POJOs

Are there any tools that auto-generate the hibernate POJOs by gathering information from the database? I made a perl script to do this after the schema got changed for the third or fourth time in a project i'm working with and just wondered if there is any established tool that will do this for me as my script is rather crude and needs ...

How to use a Oracle function for the ID in Hibernate

Hi, Until recently we used Oracle sequences to generate the IDs of a table. This is now changed, a new ID is now calculated by an Oracle function. Which means that my application needs a change to adept to the new situation. The application is a Spring/Hibernate webApp, which access the Oracle database. This was configured in an hbm.xml...

Howto bring a Java window to the front?

We have a Java-application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application. In order to get this we have realised in the called method of the Class which represents the Frame of our application (extension of a JFrame) following implementation: setVisible(true); toFront(); ...

Problem running a Jar file

I've compiled a java project into a Jar file, and am having issues running it. When I run: java -jar myJar.jar I get the following error Could not find the main class: myClass The class file is not in the root directory of the jar so I've tried changing the path of the main class to match the path to the class file and I get the s...

Embedding an application inside another application

I'm sure some of you noticed that if you have Acrobat Reader ( or any other pdf viewer ) , and open a pdf in Firefox , you will see it embedded inside your tab . Is there any way to embed an application in a JFrame ? ...

Java Transport.send() is it thread-safe?

The method is static, but I cannot find mention of if it is thread-safe or not. I plan on hitting this method with several threads at once and I would like to avoid a synchronized block if possible. javax.mail.Transport.send(msg); ...

How to store a java.util.Date into a MySQL timestamp field in the UTC/GMT timezone?

I used a new Date() object to fill a field in a MySQL DB, but the actual value stored in that field is in my local timezone. How can I configure MySQL to store it in the UTC/GMT timezone? I think, configuring the connection string will help but I don't know how. There are many properties in the connection string like useTimezone, serve...

Best java mvc framework implementation for web apps

What is the best MVC framework inmplementation in java? It has to be: lightweight KISS philosophy be able to make changes to the views without compile minimalistic; few lines of code ...

How to set the body URL of a tile in Struts action class?

I am using struts 1.1 with tiles. I have tiles with definitions like <definition name="cnmp.body.index" extends="cnmp.mainLayout" > <put name="title" value="CNM Portal" /> <put name="bodytitle" value="Home" /> <put name="body" value="/00-CNM_Landing.jsp" /> </definition> I want to be able to set the value of the body parame...

Best free tool to build an exe from Java code?

I've used JSmoothGen in the past, but recently we've seen a number of machines that refuse to run the .exes that it generates. It also seems not to be actively maintained so heavily any more. Are there any alternatives that are more actively maintained and more reliable? ...

Message Oriented Middleware (MoM) Vs. Enterprise Service Bus (ESB)

I come from a background of MoM. I think I understand ESB conceptually. However, I'm not too sure about the practical differences between the two when it comes to making a choice architecturally. Here is what I want to know 1) Any good links online which can help me in this regard. 2) Can someone tell me where it makes sense to use on...

Java: How to test methods that call System.exit()?

I've got a few methods that should call System.exit() on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since System.exit() terminates the JVM, not just the current thread. Are there any common patterns for dealing with this? For example, can I ...

In Java how do a read/convert an InputStream in to a string?

If you have java.io.InputStream object how should you process that object and produce a String? Suppose I have an InputStream that contains text data, and I want to convert this to a String (for example, so I can write the contents of the stream to a log file). What is the easiest way to take the InputStream and convert it to a Strin...

Windows shortcut (.lnk) parser in Java?

I'm currently using Win32ShellFolderManager2 and ShellFolder.getLinkLocation to resolve windows shortcuts in Java. Unfortunately, if the Java program is running as a service under Vista, getLinkLocation, this does not work. Specifically, I get an exception stating "Could not get shell folder ID list". Searching the web does turn up ment...

integrating Grails and GWT

Hi, GWT seems like a really nice technology for Java developers who don't like (or don't know) HTML/JS/CSS to build rich web interfaces. On the server-side Grails also looks really nice, it's often described as "Rails for Java developers". I've read that Grails' "convention over configuration" approach, together with the benefits of dyn...

Should Helper/Utility Classes be abstract?

I commonly find myself extracting common behavior out of classes into helper/utility classes that contain nothing but a set of static methods. I've often wondered if I should be declaring these classes as abstract, since I can't really think of a valid reason to ever instantiate these? What would the Pros and Cons be to declaring suc...

How do I stop the Sun JDK1.6 builtin StAX parser from resolving DTD entities

I'm using the StAX event based API's to modify an XML stream. The stream represents an HTML document, complete with DTD declaration. I would like to copy this DTD declaration into the output document (written using an XMLEventWriter). When I ask the factory to disregard DTD's it will not download the DTD, but remove the whole statement a...

What Cases Require Synchronized Method Access in Java?

In what cases is it necessary to synchronize access to instance members? I understand that access to static members of a class always needs to be synchronized- because they are shared across all object instances of the class. My question is when would I be incorrect if I do not synchronize instance members? for example if my class is...

How can I make a swing JButton repeat its action when it is held down?

I am creating an touch screen application using Swing and have a request to change one of buttons so that it will behave like a keyboard when the button is held down. (First of all, I am not sure that the touch screen will allow the user to "hold down" the button, but pretend that they can for now) I was going to go down the path of sta...