java

read file in classpath

Here is what I want to do and I am wondering if there is any Spring classes that will help with implementing. I don't have to use spring for this particular problem, I'm just implementing it with everything else. In my DAO layer I want to externalize my sql files aka 1 sql per file. I want to read and cache the sql statement even maybe...

com.liferay.util.PwdGenerator

Quick question: what jar do i need to add to the classpath for com.liferay.util.PwdGenerator? I have tried a few but haven't found one that works yet. thanks ...

Simple exception handling in Java

Can you please let me know if my code is correct? I'm studying for my test in two hours so I dont really have time to write an application to test it. Question is: if I have a JLabel with a number as its label. simply a label that says 34 for example. I want to extract the number from the label. but i need to handle exceptions, i.e i...

How can I disable all images for an JFace menu but leave them enabled in the toolbar

If I create a set of actions to be used in a JFace application and I assign images to those actions, those images show up in both the toolbar (where I want them) and in the menus (where I don't want them). Other than supplying two completely separate sets of actions (which eliminates part of the point of actions in the first place), how...

NullPointerException while using put method of HashMap

The following code is giving me a NullPointerException. The problem is on the following line: ... dataMap.put(nextLine[0], nextLine[6]); What is strange is that I have run this code without the above line and the call to nextLine[0] and nextLine[6] work exactly as expected - that is they give me back elements of a csv file. I declar...

Securing java runtime data on an untrusted client

I'm not even sure if this is possible, but is it feasible to secure, end-to-end runtime data on an uncontrolled client? Specifically, is there any functionality in Java to take in encrypted data, process it and send it back out encrypted, all without exposing the data in plaintext to a curious 3rd party that has full access to the clien...

Aggregation verses Composition

I've had a hard time understanding the difference between composition and aggregation in UML. Can someone please offer me a good compare and contrast between them? I'd also love to learn to recognize the difference between them in code and/or to see a short software/code example. Edit: Part of the reason why I ask is because of a revers...

Java runtime vs OS calls

The Java runtime provides a set of standard system libraries for use by programs. To what extent are these libraries similar to the system calls of an operating system, and to what extent are they different??? ...

Simulate app.config for Java?

I know that you can use java.util.Properties to read Java properties files. See: http://stackoverflow.com/questions/212539/java-equivalent-to-app-config Is there a standard place to put this file? In .NET we put application.exe.config in the same directory as application.exe. The application looks for it here by default. Java can be m...

How to batch delete using bulkUpdate

I have a common User / Role setup, with a user_role join table. I'm trying to use Spring's HibernateTemplate to mass delete all locked users like this: getHibernateTemplate().bulkUpdate("delete from User where locked=?", true); If the user being deleted does not have any roles (no record in the user_role table), then everything goes f...

Java reflection

How can I access an inherited protected field from an object by reflection? ...

Pathfinding 2d java game?

Hi all, First time on StackOverflow, keep see it coming up so thought id ask. Im currently writing a very basic java game based on the idea of theme hospital. I'm quite new to java, currently studying at uni and in my first year. I have done java for nearly 2 years now on and off, but I'm finally devoting my time to a decent project. A...

Java persistence in database

What is the simplest way to use database persistence in Java? I know, many frameworks exists around the Internet, but it could be fun to learn how to develop a persistence layer by myself and its design patterns. Where to start? Books, websites, how-tos, code-examples, etc. Thank you. ...

2d path finding with multiple possible end points?

I currently have another question to do with path finding in Java. However I feel this is a separate question. I'm making a game. The path-finding will need to be able to deal with multiple possible end points. All the path finding algorithms and tutorials I have found only have one end point. Would this alteration be easy to tweak int...

How to save a Java FloatBuffer (or any Buffer) to a file

I have a FloatBuffer of known size and just want to dump the data to a file (in binary) for inspection outside my app. What's the easiest way to do this? ...

Mapping enum to a table with hibernate annotation

I have a table DEAL and a table DEAL_TYPE. I would like to map this code: public class Deal { DealType type; } public enum DealType { BASE("Base"), EXTRA("Extra"); } The problem is that the data already exist in the database. And I'm having a hard time mapping the classes to the database. The database looks something like that...

Comparing Character, Integer and similar types in Java: Use equals or ==?

I wanted to make sure about something in Java: If I have a Character or an Integer or a Long and those sort of things, should I use equals or is == sufficient? I know that with strings there are no guarantees that there is only one instance of each unique string, but I'm not sure about other boxed types. My intuition is to use equals, ...

How can I tell which submit button was clicked

I have several different submit buttons on my JSP in one form tag that all point to the same servlet. I need to know which submit button was clicked. Ho can I find out which button was clicked? Regards ...

Intent of Spring form command

Spring's form controller (such as SimpleFormController or BaseCommandController) uses commands to pass data between the HTML form and controller. My question is, is it common practice to use the backing model as the command itself? Or is it common to create a separate command with correspond attributes to those in the backing model. My ...

spymemcached (Java Memcached Client)

Is there a way to collect the memcached stats using this API (spymemcached)? I know there are tools like cacti to collect information on Memcached Server. But I would like to collect, say, memory usage by each item I have put into the server--the total no. of items in the same category, etc... more importantly, the bytes used by individ...