java

What options do I have for retaining past values of a java object? An audit log or List<Object>?

Hi, Take my domain class for example public class Person { private Integer id; private String name; private String address; private String telephone; //Accessors here.. } This is great for storing 1 instance of a given Person, however, the name for example would most likely change over time, and I would like to retain any ...

Java: edit and recompile .jar?

I downloaded JGraphT, and I want to make some changes to the core files. I'm using Eclipse. It wants a .jar or .zip to attach source files to the .class file. I have the .java file, but I'm not sure what I should do. Do I edit it, then recompile the jar? ...

Cant get Java Timer working (javax.swing.Timer)

So I'm trying to learn how the javax.swing.Timer works, but I can't get it to do a simple operation. Basically all I'm trying to do is have the system print out "test2" every second, but it seems the actionPerformed method is never called. What am I doing wrong? import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ...

Hibernate is much faster when executing a native query.

The following query is supposed to return about 800 objects. The problem is that hibernate actually executes 800 queries to get them all. It appears to execute one query to get the ids and then executes one query for every object to get the specific data about the object. It takes over 60 seconds for this query to return. List<AUser> re...

Traversing a Binary Tree with multiple threads

So I'm working on a speed contest in Java. I have (number of processors) threads doing work, and they all need to add to a B-Tree. Originally I just used a synchronized add method, but I wanted to make it so threads could follow each other through the tree (each thread only has the lock on the object it's accessing). Unfortunately, even ...

JEditorPane can't take Google search queries, why?

Hi, I am creating a very basic web browser using JEditorPane just to teach myself Swing and GUIs in Java but am having trouble implementing a Firefox-like Google Search bar. I'm not if it's due to a limitation of JEditorPane or my lack of understanding but if I try and take the string typed into the "Google Search" bar and use the setP...

What the performance of Festival TTS vs FreeTTS on windows platforms?

9 hours ago I had the wonderful idea to build up from scratch Festival TTS on Windows. In the meanwhile, and in less than 30 minutes, I build up the same source code on Linux, but only because tons of development tools were already installed :D Also this morning I downloaded FreeTTS. I started a simple testing project in less of 10 min...

Java JDIC error message

I have the following line in my Java app, and it's causing the following error message : WebBrowser webBrowser=new WebBrowser(); org.jdesktop.jdic.init.JdicInitException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect at org.jdesktop.jdic.init.JdicManager.initBrowserNative(Unknown Sour...

Is synchronized needed here

I have a java applet. A class inside that applet is creating a thread to do some work, waiting 30 seconds for that work to complete, if its not completed in 30 secs it sets a Boolean to stop the thread. The wait and Boolean change are in a synchronized block, Is this necessary considering there is no other thread running aside from these...

getSize(), getWidth(), getHeight() returns -1

I have an Image img that, when trying to use any of above mentioned get methods, returns -1. Why is this? And what is an ImageObserver object? ...

In JBoss can I configure a "shared library" location?

I am using JBoss 4.2.2.GA app server in a development environment. I have a WAR file, MyWar.war, and a JAR file ExternalJar.jar. These files are structured in the following way: Application WAR file: MyWar.war | |--- AppClass1.class | |--- AppClass2.class External jar file (provided by client): ExternalJar.jar | |--- ExternalClass.c...

arraylist with objects does not hold the values

I have a class called Technician public class Technician { private String empLName; private String empFName; private int empId; //I skipped all setters and getters } In other class I retrieve all technicians names and load them into the array list. Technician empl = new Technician(); ArrayList <Tech...

How to asynchronously call a method in Java

Hi, I've been looking at Go's goroutines lately and thought it would be nice to have something similar in Java. As far as I've searched the common way to parallelize a method call is to do something like: final String x = "somethingelse"; new Thread(new Runnable() { public void run() { x.matches("something"); ...

Stream MTOM Web Services in Spring Web Services Framework

I would like to send large files from the server to the client using MTOM and Spring WS. I realize that this isn't the best approach for this type of thing, but it's a requirement. I have MTOM set up and it works great for small files around 50mb. I am experiencing out of memory errors for larger files and by changing different heap spac...

Help to create a generic class to avoid code duplication

I have a simple problem try to stay DRY using Appengine. The 2 functions below are identical except for the object sent as parameter. In reality I have 15 functions like this. I am try to find a way to create a super class or a generic to achieve this. public void deleteRecord(Person s) { PersistenceManager pm = PMF.get().getPersist...

How can I get Maven to generate a jnlp for my project?

I'd like to have Maven2 generate a .jnlp (webstart profile) for my application. There is a maven-jnlp-plugin, but it's deprecated as of somewhere around Maven 1.1-beta2. Is there a more preferred way to do this, or do I need to build out this capability myself? ...

How do I run a class in a WAR from the command line?

I have a Java class which has a main and I used to run as a standalone app from the command line e.g. java -jar myjar.jar params I needed to repackage the code to run under apache and all my code, including the entry point class from the old jar, has ended up in a WAR file for easy deplyment into the web server. However, I still want...

Java regex help

A string must not include spaces or special characters. Only a-z, A-Z, 0-9, the underscore, and the period characters are allowed. How do I achieve this? Update: All the solutions posted worked for me. Thanks everyone for helping out. ...

Intellij generate javadoc for methods and classes

Hi. Is it possible to set up Intellij to generate javadoc for methods and classes, automatically, with @author and @since date ? I had this feature in Eclipse. I know, that files have templates and also i can manually semi-automatically add javadoc to selected method/class. But i want the generation to be automatic for every generated ...

Execute a task after the modelAndView is returned

In Spring, is there a way to execute a task after returning a view or I need to create a ThreadPool and do it ? Ex: public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<Object, Object> data = new HashMap<Object, Object>(); //do some stuff exe...