java

Efficiently iterate through all MATCHING keys in a hashmap?

I have a HashMap with millions of entries. Need to retrieve all entries whose keys match a specific set of criteria (in this case, each key is an object with two integer properties; I need to retrieve all keys where each of these integers fall within a specified range). What is the fastest, most efficient way to iterate through all suc...

Why does JRuby not recognize BigNums while Ruby does?

If I type this big integer: puts 9997836544.class.to_s and compile with ruby 1.86, it reports expectedly: BigNum while JRuby (1.1.4 in Netbeans) reports surprisingly: Fixnum I thought Java had a BigInteger class to correspond to the BigNum class in Ruby. If so, I would have expected JRuby and ruby to produce the same output. ...

Use aspectj to profile selected methods

I'd like to use aspectj to profile a library. My plan was to mark methods that require profiling with an annotation: @Profiled("logicalUnitOfWork") And then have an aspect that would fire before and after methods that would use the logicalUnitOfWork to highlight the profiled content. So, my pointcut to start with looks like this. No...

Does the Eclipse Web Tools Project handle refactoring inside JSPs?

I've installed the Web Tools Project for Eclipse version 3.4. I've been trying to get refactoring working the way I think it should and have had no success. I have one Java project that contains the Java classes for the jar that is put into the /WEB-INF/lib for a web site. Another project (a Dynamic Web project) has the JSP files for ...

Java GUI Problems

I'm designing a really simple GUI but without any luck. Basically the outer layout has two columns which is a splitter pane (this is for an IRC client I'm writing). On the left-hand side is the server/channel/user tree and on the right is the chat pane. Now I break this down so on the right-hand side there's the output pane at the top...

How do I get Java "hot code replacement" working in JBoss?

I am running JBoss 4.0.3.SP1_CP04 and connecting to it with Eclipse 3.4.1's debugger, both using JDK 1.6.0_11. When I make a minor change to a method (e.g. changing a "+ 1" in the logic to a "+ 2") and save it, I immediately receive an error message dialog titled "Hot Code Replace Failed" with the error "Delete method not implemented" ...

Pros and Cons of Various Java Web Presentation Layer Technologies

I'm currently working on a web app that makes heavy use of JSF and IceFaces. We've had some discussions of moving to another presentation layer, and I thought I'd take the discussion out into SO and see what the experts think. I'm curious if anyone could weigh in on the pros and cons of the various Java presentation layer technologies....

Are Java and C# regular expressions compatible?

Both languages claim to use Perl style regular expressions. If I have one language test a regular expression for validity, will it work in the other? Where do the regular expression syntaxes differ? The use case here is a C# (.NET) UI talking to an eventual Java back end implementation that will use the regex to match data. Note that...

Is it possible to use xpath in java to get the contents of a cdata node with HTML in it

example... <xml> <level1> <level2> <![CDATA[ Release Date: 11/20/09 <br />View Trailer ]]> </level2> </level1> </xml> when I use inFeed.getXpath().evaluate("xml/level1/level2", myNodeList); I get "Release Date:11/20/09 View Trailer" I was under the impression that the whole point of CDATA is that it preserves whatever mumbo jumbo yo...

How to put Google Adsense in GWT

Do anyone know how to put Google adsense ads inside a GWT web application? ...

Java equivalent of register int?

In C, I can allocate a register for a variable, for example: register int i = 0; I am aware that Java is an interpreted language, and is many many abstractions away from the CPU. Is there any mechanism available to even request (and if the architecture doesn't allow it, so what) that my variable remains in a register instead of movin...

Java - static methods best practices

Let's say I have a class designed to be instantiated. I have several private "helper" methods inside the class that do not require access to any of the class members, and operate solely on their arguments, returning a result. public class Example { private Something member; public double compute() { double total = 0; ...

Launching background threads on GWT startup

I have a GWT application that displays some charts rendered by JFreeChart. Every few minutes, the page refreshes, which causes the app to generate new charts. (In other words, the entire chart generation process is bootstrapped by a client request.) The problem with this is that multiple clients hitting the same server would result in mu...

java.lang.UnsatisfiedLinkError in Linux.

Hello. I've managed to get into a linux machine to try the HotKey library suggested in this answer. I've compiled the sample code and now I run the program and I've got the following message: [oracle@machine jxgrabkey-0.2.1_i386]$ java -classpath lib/JXGrabKey.jar:Example JXGrabKeyTest Exception in thread "main" **java.lang.Unsatis...

Playing a sound notification using Google Web Toolkit

Is it possible to play a sound notification using Google Web Toolkit which will be translated to Javascript? Thanks. ...

java.util.Scanner and Wikipedia

Hi, I'm trying to use java.util.Scanner to take Wikipedia contents and use it for word based searches. The fact is that it's all fine but when reading some words it give me errors. Looking at code and making some check it turned out that with some words it seems not to recognize the encoding, or so, and the content is no more readable....

Does .NET JIT optimize empty loops away?

This article suggests otherwise. But there is still a need to evaluate the loop condition. Does java just employ a specific trick to recognize this case? ...

Best Way to Constantly Update GUI Elements

Hi All I have a Java GUI that has a number of text fields, the values of which are populated from static variable in another class. I am interested to know what the best way is to make it so that when the variable is changed in another class, the update is instantly reflected on the GUI. If any one could make a suggestion on an effici...

Best Embedded SQL DB for write performance?

Has anybody done any benchmarking/evaluation of the popular open-source embedded SQL DBs for performance, particularly write performance? I've some 1:1 comparisons for sqlite, Firebird Embedded, Derby and HSQLDB (others I am missing?) but no across the board comparisons... Also, I'd be interested in the overall developer experience for ...

How do you use the output of one servlet inside another servlet's init() method?

Here's what I'm trying to do: public void init(ServletConfig config) { // ... URL url = new URL("http://myhost:port/path/to/otherservlet"); // ... do stuff with contents of url } This works fine, but myhost and port are hardcoded and I want to avoid that. I want URL url = new URL("/path/to/otherservlet"); but that's not...