java

Create .exe for Java program

Hi, I'd like to create a Windows .exe for a Java program. Previously, I've used JEXECreator for this, but it's not entirely satisfactory because: The executable sometimes work on the machine on which it was created but not on others The program is comercial. If you use the trial version it adds a nag screen to your application. I do...

Best practices in internationalizing text with lots of markup?

I'm working on a web project that will (hopefully) be available in several languages one day (I say "hopefully" because while we only have an English language site planned today, other products of my company are multilingual and I am hoping we are successful enough to need that too). I understand that the best practice (I'm using Java, ...

How to transfer java array to javaScript array using jsp?

Hello all, I have a list of strings on my server which I am trying to get to the client in the form of an array. The code I am attempting to use is the following: Within the jsp I have a List<String> columns. I am attempting the following code: <%int j = 0; %> for(var i = 0; i < <%=columns.size()%>; i++) {   colArray[i] = "<%=column...

Increment a Hex value (JAVA)

Hi, can you increment a hex value in Java? i.e. "hex value" = "hex value"++ ...

If-less code: is it just an intellectual challenge or is it concretely useful?

A friend of mine is talking about these design techniques regarding state transitions of an object (he's a Java guru, btw), performed without having a boolean myState member, but rather declaring the myState member as an object that implements the same interface of the "owner" one. Ok, I've been too much cryptic, so you can find the dis...

Using "this" with methods (in Java)

Exact duplicate by same poster: http://stackoverflow.com/questions/516291/the-use-of-this-in-java Hello, what about using "this" with methods in Java? Is it optional or there are situations when one needs to use it obligatory? The only situation I have encountered is when in the class you invoke a method within a method. But it is op...

How assign bean's property an Enum value in Spring config file?

I have a standalone enum type defined, something like this: package my.pkg.types; public enum MyEnumType { TYPE1, TYPE2 } No I want to inject a value of that type into a bean property: <bean name="someName" class="my.pkg.classes"> <property name="type" value="my.pkg.types.MyEnumType.TYPE1" /> </bean> ...and that didn't ...

Mixed language source directory layout

We are running a large project with several different languages: Java, Python, PHP, SQL and Perl. Until now people have been working in their own private repositories, but now we want to merge the entire project in a single repository. The question now is: how should the directory structure look? Should we have separate directories for...

Has anybody real world experience with buckminster?

I'm currently evaluating ivy, maven and buckminster to ease our build process. Conceptually buckminster seems the most advanced, but also to have quite a complexity. I can't find so many first hand experiences to buckminster on the web, therefore my question to the Stackoverflow community. ...

Java: Image as toggle button

Hi guys, How can I create in a Swing interface a toggle image button? I have two images, imageon.jpg and imageoff.jpg,and I basically want a clickable element that toggles the images and fires an event. Update: Is there a way to override the usual 'chrome' around the image? I would prefer a simple image to a button with an image inside...

How do I set an cache time for objects in OSCache using spring-modules?

I have an application in need of some caching, and for some of the semi-static data, I want them to stay in the cache a maximum amount of time (for instance 10 minutes) before being refreshed. My system merely retrieves data, never updates it, so I have no idea of when to flush the cache using the property. In the OSCache docs, such an ...

Find the classname of a UI control

Hi, I need a tool which tells the classname of the UI control on which my mouse pointer is. My GUI is in Swing. Does such a tool exist? ...

How to design DAOs when the datasource varies dynamically

Usually when defining a DAO, you would have a setter for the datasource on the DAO object. My problem is that our datasource varies dynamically based on the request to the server. i.e. every request can access different database instance. The request holds logical properties, that later can be used to retrieve the connection to the DB o...

Is it OK to have two frameworks in the same project?

So I have taken over a Java Web project. The application was written by another developer who now works for another company. Generally speaking, the application is straightforward, well designed and the code is documented enough. The only issue is that the previous developer decided to built his own database access library instead of usi...

jvm design decision

Why does the jvm require around 10 MB of memory for a simple hello world but the clr doesn't. What is the trade-off here, i.e. what does the jvm gain by doing this? Let me clarify a bit because I'm not conveying the question that is in my head. There is clearly an architectural difference between the jvm and clr runtimes. The jvm has a ...

spring not enforcing method security annotations

I'm some what lost as to why spring isn't enforcing the @Secured("ROLE_USER") on my service interface. My controllers are established using annotations. An example of my service Interface public interface MyServiceManager { @Secured("ROLE_USER") public void delete(int cid); @RolesAllowed({"ROLE_USER"}) public Contact...

Right-click context menu for Java JTree?

I'm trying to implement pop-up menus in Java JTree. I've sub-classed DefaultTreeCellRenderer (to change node appearance) and DefaultTreeCellEditor (to create Components to attach event listeners to, since apparently the Components that DefaultTreeCellRenderer.getTreeCellRendererComponent() returns can't do it?). I don't really want to "e...

Java: Array of primitive data types does not autobox

I have a method like this: public static <T> boolean isMemberOf(T item, T[] set) { for (T t : set) { if (t.equals(item)) { return true; } } return false; } Now I try to call this method using a char for T: char ch = 'a'; char[] chars = new char[] { 'a', 'b', 'c' }; boolean member = isMemberOf(ch, ...

How do I map a Map from an Entity to a Value with hibernate annotations?

I have Shipment and Product entities. Each shipment consists of any amount of any numbers of products. I.e. a shipment has a field named products which is a java.util.Map where they key is the product being shipped and the value is the number of instances of that product being shipped. How do I map that to a db with hibernate annotation...

When to use "strictfp" keyword in java?

Ok, I've looked up what this does, but does anyone actually have an example of when you would use the "strictfp" keyword in java? Has anyone actually found a use for this? Would there be any side-effects of just putting it on all my floating point operations? ...