java

Netbeans Obfuscation

I'm very new to obfuscation and don't have a lot of experience with ant. Come someone provide me a way to obfuscate a regular Java application with ProGuard (or any other open source obfuscator). Currently I'm using NetBeans 6.5.1, and only see the obfuscation ability if I create a JAVA ME, and not a Java Application like I have. I've...

Java object caching, which is faster, reading from a file or from a remote machine?

I am at a point where I need to take the decision on what to do when caching of objects reaches the configured threshold. Should I store the objects in a indexed file (like provided by JCS) and read them from the file (file IO) when required or have the object stored in a distributed cache (network, serialization, deserialization) We a...

rmi over ssl/tls, any way to securely identify the caller?

hi everyone, is there any way to securely get the method invoker while running the called method (server-side)? i know there's a client string reachable through the server properties, but isn't it too "weak"? any way to get e.g. the client certificate owner? please give me a couple of hints, WILL RTFD right afterwards ;) thanks in ad...

Controling the size of components in Swing when their frame is resized

I have a simple form like this: Username: .......... Password: .......... When the form is re-sized, I would expect JTextField (illustrated by .........) to be re-sized horizontally to fit the new width but not vertically (the same height for JTextField). Do we have any way to control this? Thanks! ...

How to make Jpanel expand to the size of the JFrame?

The below code is from the book objects First With Java By Michale Kolling and David J Barnes and the following is an exercise (ex 5.49) from the book.The ex is : Improve your drawFrame method to adapt automatically to the current canvas's size.To do this you need to find out how to make use of an objectof class Dimension. In the follow...

Accessing HttpServletRequest from AOP advice in Spring 2.5 with annotations

Hi All, I have tried to find the answer to this question on both the Spring forum and by searching StackOverflow. I have found a lot of pages describing horrible architectures and asking for about the same thing as I do, but my intended usage is different so please bear with me :-) I have a Spring 2.5 project using annotation based for...

Swing: Can't get JButton to update - repaint() not working

I'm using Swing for the first time to create a simple GUI. It consists of a JFrame upon which I have placed a single JButton which, when clicked, calls some other code which takes approx. 3 seconds to return. Just before the call to this code, in actionPerformed(), I want to update the text on the button to inform the user that processi...

ObjectInputStream Error

I am using ObjectOutputStream to create a file of serialized objects. I then use an ObjectInputStream to with the readObject() method to get the objects back out of the file. It works great the first time. Meaning that if the file does not exist and I open it then append any number of objects, I can open the ObjectInputStream object a...

Quick Fix Java Error ArrayIndexOutOfBoundsException

Am I just to blind to see the solution? sampleSum = 0; for(int x : sampleWeights) sampleSum += x; population = new int[sampleSum]; int z = 0; for(int i = 0; i < nsamples; i++) for(int j = 0; j < sampleWeights[i]; j++) { population[z] = i; z++; } Any help is appreciated! Thanks! ...

What is the best method to GZIP a JSF-Seam web app pages

Hi, I'm developing an JSF web app on Tomcat, planning to use Seam in the near future, and I want to add compression of our web pages and resources (i.e. Javascript & CSS files). I'm aware of three methods to GZIP responses in a Java web : Use Ehcache GZIP filter: it's used in Appfuse, so it's probably solid and it checks if the user a...

How can I customize Eclipse's getter and setter generation?

How can I configure Eclipse to generate getters and setters with some prefix for argument variable? Example: private String someVariable; public void setSomeVariable(String aSomeVariable) { this.someVariable = aSomeVariable; } ...

Sleep OS X from Java

Hi, Really simple little function, but does anyone know how to sleep OS X from Java? Cheers ...

Is it possible to run Java ME apps in Palm Z22?

I want to develop a java app that should run in Palm Z22. Will it be possible? If you could provide me some start point I would appreciate. ...

Unknown source of ClassCastException (in JTables)

I'm presently refactoring a JTable which displays a multitude of different types of data. The primary reason for this refactoring is that there a few ClassCastExceptions (the author/friend who wrote the code is off on hiatus), and I can't seem to find where these are originating from. Due to the large codebase, I'm at a loss as to where ...

Recursive Array Traversal Problems

Hello everyone, I am having some stackoverflow issues and hopefully someone can give me some insight into a non/less-recursive solution. Ident[][] map = ... private int explore(Ident item, int xcoord, int ycoord) { if ((map[xcoord][ycoord] == null) || !map[xcoord][ycoord].equals(item)) return 0; map[xcoord][ycoor...

How do I get a keyIterator for a LinkedHashMap?

By looking at the source code for LinkedHashMaps from Sun, I see that there is a private class called KeyIterator, I would like to use this. How can I gain access? ...

What are the pros and cons of LinkedHashMaps vs. LinkedHashSets?

I was just wondering if someone could espouse for me the main benefits for choosing one over the other and the detriments that come with that choice. ...

Java short style if evaluation

I can't find the relevant portion of the spec to answer this. In a conditional operator statement in Java, are both the true and false arguments evaluated? So could the following throw a NullPointerException Integer test = null; test != null ? test.intValue() : 0; ...

Is it worth wrapping a logging framework in an additional layer?

I'm currently looking at upgrading the logging mechanism in a medium-to-large-sized Java codebase. Messages are currently logged using static methods on a Debug class, and I have recommended switching from this to something like SLF4J or commons-logging. The application architect prefers that I encapsulate the dependency on SLF4J (possi...

hibernate not using where clause with inner join

Here's an excerpt from my code (I'm using XDoclet): /** * @hibernate.class table="WIP_DISCRETE_JOBS" */ public class WipDiscreteJob extends AuditedObject { private WipDiscreteJobStatus status; /** * @hibernate.many-to-one column="STATUS_TYPE" */ public WipDiscreteJobStatus getStatus() { return status; } } /** * ...