java

Data Structure Brushup (Java)

This should be easy for many of you, but for me it's just another bit of rust needing to be chipped away as I get back into basic Java coding. Using bloody associative arrays for so long in other languages have turned me nice and spoiled. :P My problem is simple: I'm storing a set of objects, each containing a string and a number, in a...

Earley parser generator for Java

I'm looking for an Earley parser generator that is able to generate Java output code, i.e. that generates Java code for the lexer and parser, and allows to include actions (realised as Java code) that are performed for the grammar rules. I looked at two Earley parser generators that generate Java code (Pep and PEN) but none of them seem...

Looking for a regular expression to identify hard coded magic numbers in source code

A frequent issue in code reviews is whether a numeric value should be hard-coded in the code or not. Does anyone know of a nice regular expression that can catch 'magic numbers' in code like: int overDue = 30; Money fee = new Money(5.25D); without also getting a ton of false positives like for loop initialization code? for (int i = 0...

Limit Java Console heap footprint?

I have a Java applet (an actual <APPLET>) which generates frequent log messages to System.out. If the Java Console is enabled in the user's browser, it will of course retain references to all of these strings and prevent them from being garbage collected. The problem is the number of log messages the console retains: the applet heap grow...

Making a Service Layer call from Presentation layer

I have to choose a technology to connect my Application/Presentation Layer (Java Based) with the Service Layer (Java Based). Basically looking up appropriate Spring Service from the Business Delegate Object. There are so many options out there that it is confusing me. Here are the options I've narrowed down to but not sure.. Spring RM...

What is a good embeddable Java LDAP server?

I'm working on a Java web application that integrates with a few other external applications that are deployed along with it. Authentication information must be synchronized across everything and the other applications want to authenticate against LDAP. The application will be deployed in environments where there will be no other LDAP se...

Can I force generation of a JVM crash log file?

The log file from a JVM crash contains all sorts of useful information for debugging, such as shared libraries loaded and the complete environment. Can I force the JVM to generate one of these programmatically; either by executing code that crashes it or some other way? Or alternatively access the same information another way? ...

How can you ensure in java that a block of code can not be interrupted by any other thread.

exampl: new Thread(new Runnable() { public void run() { while(condition) { *code that must not be interrupted* *some more code* } } }).start(); SomeOtherThread.start(); YetAntherThread.start(); How can you ensure that code that must not be interrupted won't be interrupted? ...

How to test HttpSessionListener.sessionDestroyed in Java webapp?

How might a person simulate firing the HttpSessionListener.sessionDestroyed object in a session listener? Is just setting the Tomcat session timeout to 1 and then waiting the only way? ...

Which are the examples for contra guideline implementations/misnomers in .net/java framework?

I can remember Convert class in .net which is named not in accordance with the guide lines. Any more examples? ...

Java Programming Guidelines

What Java Programming Guidelines you are using? I know that the most common is the one provided by Sun (http://java.sun.com/docs/codeconv/) but I would like to know if there are other market standards. ...

Switch Statement With Strings in Java?

Simple question -- why can't I switch on a String in Java, and as far as anyone knows, is this functionality going to be put into a later Java version? EDIT: If someone can point me to an article, or themselves explain why I can't do this, as in, the technical way Java's switch statement works, it would be most appreciated. UPDATE: Alo...

Architecture - Multiple web apps operating on the same data

I'm asking for a suitable architecture for the following Java web application: The goal is to build several web applications which all operate on the same data. Suppose a banking system in which account data can be accessed by different web applications; it can be accessed by customers (online banking), by service personal (mostly read...

Java Tag Library for compairing two objects via the equals method.

In my JSP I'm required to compare to Objects to see if they are equal or not using the Object's equals method. Is there a way to do this using the JSTL or another Tag Library? (I am not allowed to use Scriptlets due to team rules.) I tried to use the JSTL tag, but it only seems to use the == operator. Any suggestions are appreciated...

Any tutorials on public key encryption in java?

I've been able find information on symmetric encryption and hashing but I've been having quite a bit of trouble finding much information on any sort of public key encryption for java. What I'd like to do is make a very simple proof of concept program that takes a string ( or a file I suppose), encrypts it with a public key and then decry...

A better Java JSON library?

Can anyone recommend a good Java JSON library (better than the one from http://json.org/)? I've also found JSON-lib, which definitely looks like an improvement, but I'm wondering if there is anything that is even better than that? ...

Can I write to the end of a 5GB file in Java?

Can I write to the end of a 5GB file in Java? This question came up in my office and no one is sure what the answer is. ...

Java VM: IBM vs Sun

I'm surprised at how little information I can find comparing IBM's jvm to Sun's. How do they compare? I have always used Sun's version - what are the reasons (if any) to consider switching to IBM's? EDIT: To phrase the question a little differently: For those of you who use IBM's jvm, what are your reasons? ...

Simple Variables in Java & C++

I saw this sentence in some matrials: "In Java, simple data types such as int and char operate just as in C." I am wondering that actually they are different in Java & C++? In C++, simple variables like the primitives in Java are assigned a memory address as well, so these primitive types in C++ can have a pointer as well. However pri...

Java Generics: Generic type defined as return type only

I'm looking at some GXT code for GWT and I ran across this use of Generics that I can't find another example of in the Java tutorials. The class name is com.extjs.gxt.ui.client.data.BaseModelData if you want to look at all of the code. Here are the important parts: private RpcMap map; public <X> X get(String property) { if (allowNes...