When a class field is accessed via a getter method by multiple threads, how do you maintain thread safety? Is the synchronized keyword sufficient?
Is this safe:
public class SomeClass {
private int val;
public synchronized int getVal() {
return val;
}
private void setVal(int val) {
this.val = val;
...
I have done some searches looking for information about how to do logging with the Spring Framework.
We currently have an application that has no logging in it except for system.out statements (very bad way).
What I would like to do, is add logging, but also want to be able to control the logging at run time, with say JMX.
We are usin...
Can anyone suggest a good way of detecting if a database is empty from Java (needs to support at least Microsoft SQL Server, Derby and Oracle)?
By empty I mean in the state it would be if the database were freshly created with a new create database statement, though the check need not be 100% perfect if covers 99% of cases.
My first th...
Do you know any libraries similar to java.util.Properties that support more advanced features like grouping properties, storing arrays, etc?
I am not looking for some heavy super-advanced solution, just something light and useful for any project.
Thanks.
...
How do I truncate a java String so that I know it will fit in a given number of bytes storage once it is UTF-8 encoded?
...
We've pre-defined Excel document structure with lots of formulas and macros written.
During download of Excel, thru Java application we populate certain cells in Excel with data. After download when user open Excel, macros & formulas embedded in it will read the pre-populated data and behave accordingly.
We are rightnow using ExtenXLS ...
Are there any industry standard conventions for naming jar files?
...
is there anywhere on the web free vista look and feel theme pack for java?
...
When calling a remote service (e.g. over RMI) to load a list of entities from a database using Hibernate, how do you manage it to initialize all the fields and references the client needs?
Example: The client calls a remote method to load all customers. With each customer the client wants the reference to the customer's list of bought a...
I am sending newsletters from a Java server and one of the hyperlinks is arriving missing a period, rendering it useless:
Please print your <a href=3D"http://xxxxxxx.xxx.xx.edu=
au//newsletter2/3/InnovExpoInviteVIP.pdf"> VIP invitation</a> for future re=
ference and check the Innovation Expo website <a href=3D"http://xxxxxxx.xx=
xx.xx.e...
We have our domain model declared in rusty old hbm files, we wish to move to POJOs annotated with the javax.persistence.* annotations.
Has anyone had experience doing so?
Are there tools that we could employ?
...
Our Java code (not the test code) reads files from the current directory, which means the working directory needs to be set properly whenever we run the code.
When launching a JUnit test from within Eclipse, a launch configuration automatically gets created. The problem is, that the working directory in that launch configuration is alwa...
Please suggest some good resources to start writing Java Web services.
...
I am reading image files in Java using
java.awt.Image img = Toolkit.getDefaultToolkit().createImage(filePath);
On some systems this doesn't work, it instead throws an AWTError complaining about sun/awt/motif/MToolkit.
How else can you create a java.awt.Image object from an image file?
...
I have been given the task of implementing a login handler. The only detail the handler captures is username and password. Initially I was going to use a JSP that posted to a servlet. Where the servlet carried out a db lookup and also validated the user credentials. Upon successful login you are redirected but unsuccessful takes you ...
Hello i have a problem with the design of a VetoableChangeListener:
I implement the VetoableChangeListener interface to listen changes of a property in a model class, when the model fires the
vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
i try to save the change in a DB, which could fail (by a SQLException,...
Does anyone know of any free utility jars for java that assist with longitude/latitude manipulation in Java?
I am wanting to find the distance between two different points. This I know can be accomplished with the great circle distance.
http://www.meridianworlddata.com/Distance-calculation.asp
Also, given a point and a distance I would...
Do you have any tips for effective profiling using Netbeans?
The profiler is quite nice and powerful. I've used it to find problems in some of my Eclipse RCP client applications. However, I get the feeling that I could get some more value out of it.
Normally I set it to profile either all my classes (starting with xxx.mydomain) using...
I am running JUnit through TextMate, and when I try to run my test cases I get this error
JUnit version 4.5
Could not find class: ProgTest
Time: 0.001
OK (0 tests)
Progtest.java can be found here
...
Is there anyway in Java to delete data (e.g., a variable value, object) and be sure it can't be recovered from memory? Does assigning null to a variable in Java delete the value from memory? Any ideas? Answers applicable to other languages are also acceptable.
...