java

Why does my jscrollpane result in odd paint calls in java swing?

I've got a routine that paints an insanely large graph inside a scroll pane. It's too big to paint before adding to the scrollpane - the menory requirements would be several gigs. Because of the size of the graph I'm rendering the chart within the paint method of the scrollpane's child. Which works out well, however I'm noticing that ev...

How to get JavaDoc for SWT and JFace in Eclipse?

I'm a newbie to Eclipse and can't figure out how to get the JavaDocs for SWT and JFace to show up when I am editing. How do I do this? Thanks! ...

Using JBoss 4.2.x, how can I deploy a new data source without undeploying existing ones?

Configuration management for our EE application requires us to create a new database connection datasource from time to time. We do this right now by modifying the deploy/[dbtype]-ds.xml file, inserting an additional connection definition into this file. The problem is, doing so causes the existing connections to be undeployed and rede...

Java synchronized block vs. Collections.synchronizedMap

Is the following code set up to correctly synchronize the calls on synchronizedMap? public class MyClass { private static Map<String, List<String>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<String>>()); public void doWork(String key) { List<String> values = null; while ((values = synchronizedMap...

A good 2d engine for Java ?

DUPLICATE: http://stackoverflow.com/questions/293079/java-2d-game-frameworks Does anyone knows a good 2D engine for Java with sprites, animations and colisions handling ? ...

Java Speech Example: Encode, Stream, Decode, Play

I have been trying to find an example of this that I could use for a couple years, I'm ashamed to admit. I would like to see a working, compileable example (most that I find online don't compile or don't actually work) of reading from the microphone, encoding the voice data in a speech-friendly encoding such as Speex, and streaming that ...

In log4j, is there a way to log errors based on timestamp?

log4j is logging errors based on level. Is there a way to log errors based on timestamp? ...

Apache Camel for Asynchronous Calls

Does it make sense to use Apache Camel for Asynchronous requests? Or should I use simple MoM using a JMS server. There are no Enterprise Integration Patterns that I'll require. Any help would be useful. ...

LDAP Best Practices

Hi, there. I'm interesting in best practices of using LDAP authentication in java-based web application. In my app I don't want to store username\password, only some id. But, I want retrieve addition information (Name, Last name) if any exists on LDAP catalog. ...

Developing a (file) exchange format for java

I want to come up with a binary format for passing data between application instances in a form of POFs (Plain Old Files ;)). Prerequisites: should be cross-platform information to be persisted includes a single POJO & arbitrary byte[]s (files actually, the POJO stores it's names in a String[]) only sequential access is required shoul...

Simple Java Web Service client over HTTPS

Hi all, I am connecting to a simple XML over HTTPS web service and getting a security exception. My question is whether you think the cause of this is the cert on the web server, so I should talk to the server admin or if my client code should be handling this. I would love to hear if anyone has encountered and solved this issue. Is the...

How expensive are Exceptions

Do you know how expensive exception throwing and handling in java is? We had several discussions about the real cost of exceptions in our team. Some avoid them as often as possible, some say the loss of performance by using exceptions is overrated. Today I found the following piece of code in our software: private void doSomething() {...

Calculate elapsed time in Java / Groovy

I have... Date start = new Date() ... ... ... Date stop = new Date() I'd like to get the years, months, days, hours, minutes and seconds ellapsed between these two dates. -- I'll refine the question. I just want to get the elapsed time, as an absolute measure, that is without taking into account leap years, the days of each mont...

Online compilers/runtime for Java, C++, Python and ObjC?

Does anyone know of a good online compiler/runtime (for C++, Java, Python, ObjC etc.) that I can access on the web? What I'm looking for is something that would allow me to type in a program in a web form and to run the program and see the results online. (Let's not get into the why for now. Suffice it to say for the moment that I don...

Problem running Java .war on Tomcat

I am following the tutorial here: http://nutch.sourceforge.net/docs/en/tutorial.html Crawling works fine, as does the test search from the command line. When I try to fire up tomcat after moving ROOT.war into place(and it unarchiving and creating a new ROOT folder during startup), I get a page with the 500 error and some errors in...

String delimited regular expression

I'm trying to build a bbcode parser, but I'm having quite some problems figuring out how to avoid matching too widely. For example I want to implement a [list] to conversion like this: \[list\](.*)\[/list\] would be replaced by this: <ul>$1</ul> This works fine, except if I have two lists where the regular expression matches the b...

How do I find the user's 'Documents' folder with Java in OS X?

I'd like to create a directory in the user's 'Documents' folder, but so far I've only found out how to get the user's home directory: javax.swing.JFileChooser fr = new javax.swing.JFileChooser(); javax.swing.filechooser.FileSystemView fw = fr.getFileSystemView(); this.userDirectory = fw.getDefaultDirectory(); In Windows the above code...

Is the Java API poorly designed and why?

I have heard this a lot, the the Java API is poorly designed. Do you agree and if so, how? I know there are major issues with the Calendar/Date apis. The collections api takes a lot of boilerplate code to use. The File/IO API can be complicated for some things. But, does this apply across the aboard? And to which versions of Java? ...

Can maven collect all the dependant jars for a project to help with application deployment?

I'm just starting to use Maven, (evaluating it, really) and I need to be able to quickly generate a jar for my app and a directory with all the dependencies (eg: lib) so that I can deploy those two to be run in a stand-alone manner. Generating the jar with the proper manifest is easy, but I do not know how to get maven to copy the depen...

When should I use EJB transaction attributes 'Mandatory' and 'Never'

I am referring to container managed transaction attributes in Enterprise Java Beans. I can't think of any use cases where using 'Mandatory' and 'Never' makes sense. Can anyone please explain what cases warrant using these transaction attributes? ...