java

JButton question

Can you disable a JButton without graying out the button itself? When you use setEnbaled(false), the button disables and turns to gray. Is it possible to disable the button but make the appearance of the button still the same? ...

MVC in a Google App Engine Java world

I'm coming to Java from C# & ASP.NET MVC, I'd love to find an equivalent in the Java world that I could use on the Google App Engine. I've already started to have a play with FreeMarker and even made the first steps towards writing a very simple framework. Ideally I wouldn't have to do all the hard work though, someone must have done thi...

UDP client not reachable in Java

Hi I am running a simple UDP Java Server, which collects IP and Port of Client when connected, store information in Database. Client is still listening to server. Server stops. Later, server want to reuse the database information, to reach the client; and as the client is still listening to same port of server, I guess client shoul...

Obtaining an object state

Does hibernate provide a method that returns an object's state (transient, persistent, detached)? ...

How to find annotated methods in a given package?

I have a simple marker annotation for methods (similar to the first example in Item 35 in Effective Java (2nd ed)): /** * Marker annotation for methods that are called from installer's * validation scripts etc. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface InstallerMethod { } Then, in a give...

How to ensure JVM starts with value of Xms

When I run a java program with the starting heap size of 3G (set by -Xms3072m VM argument), JVM doesn't start with that size. It start with 400m or so and then keeps on acquiring more memory as required. This is a serious problem for me. I know JVM is going to need the said amount after some time. And when JVM increases is its memory a...

Accessing private static methods from a public static context

Consider this sample class, class TargetClass { private static String SENSITIVE_DATA = "sw0rdfish"; private static String getSensitiveData() { return SENSITIVE_DATA; } } When I do this, import java.lang.reflect.Method; public class ClassPiercing { public static void main(String... args) throws Exception { ...

Overcomplicated oracle jdbc BLOB handling

When I search the web for inserting BLOBs into Oracle database with jdbc thin driver, most of the webpages suggest a 3-step approach: insert empty_blob() value. select the row with for update. insert the real value. This works fine for me, here is an example: Connection oracleConnection = ... byte[] testArray = ... PreparedStateme...

How to pass the -D Sytem properties while testing on Eclipse?

I am developing on Eclipse on Windows and Code gets deployed on Unix. I am fething the system property values using System.getProperty("key") ... how do I pass this in Eclipse so that I do not have to modify the code and it works on Eclipse for debugging? Any suggestions? ...

JSP, Parameter Passing without use of HTML Forms

I have done some research, and majority of the examples I have found use forms (obviously for user input) to collect data which is then passed to another JSP page through the request object. My question is: "Is it possible to pass a parameter between JSP pages IF the parameter hasn't been set in HTML tags?" Thankyou, Lucas ...

Optimizing a simple search algorithm

I have been playing around a bit with a fairly simple, home-made search engine, and I'm now twiddling with some relevancy sorting code. It's not very pretty, but I'm not very good when it comes to clever algorithms, so I was hoping I could get some advice :) Basically, I want each search result to get scoring based on how many words ma...

What mode to use to decrypt RSA message from iPhone in Java?

My friend has encrypted data with PKCS1 padding on an iPhone. How can I decrypt that data in Java? Java requires me to specify "algorithm/ciphermode/padding". The padding and the algorithm are known, but neither of us knows the cipher mode; it is not specified when encrypting on the iPhone. ...

How can I configure a Spring BeanFactory with several bean configuration files?

Hi all, I am sure that the above question has a straightforward answer but I couldn't easily find it (neither in the documentation nor on stackoverflow.com) I got the notion that a BeanFactory/ApplicatioContext can be initialized with several bean configuration files. Is that so? And, if it is how can it be done? ...

busy wait threads in java

Hello, I have an assignment with threads and I cant have the threads go into busy wait state. How do I know if a thread is in blocking state or in busy wait? Is there a command that checks it? In the program I have 2 matrices and I need to transform them. So I have a transform thread and the code is as follows: transformThread transfo...

Soft reference LinkedHashMap in Java?

Is there softreference-based LinkedHashMap in Java? If no, has anyone got a snippet of code that I can probably reuse? I promise to reference it correctly. Thanks. ...

.NET CLR that does not require an operating system?

In the world of Java, BEA (now Oracle) has created LiquidVM which doesn't require an OS. Likewise, there are a variety of open source projects including SANOS, JNODE OS, Project Guest VM, JavaOS, etc. Is there an equivalent being created for .NET? ...

How to call Oracle function or stored procedure using spring persistence framework?

Hi, I am using Spring persistence framework for my project. I want to call oracle function or stored procedure from this framework. Can anybody suggest how can I achieve this. Please give solution for both * oracle function and *stored procedure. Thanks. ...

Putting values in error.getModel in onBindAndValidate

I want to add some data to model if there wasn't any validation errors. I thought I could do this in onBindAndValidate, where I have the access to error object, which contains model: errors.getModel().putAll(map); I also tried to put values one by one using put(key, value) but without success. What can I do? ...

JVM garbage collection and a paging memory architecture

In the recent 10 year when discussing java and/or garbage collection, the only performance penalty that I have not been able to defend is that garbage collection algorithms more or less breaks when running in a paged memory architecture, and parts of the heap is getting paged out. Unix systems (and especially Linux) agressively pages ou...

Netbeans external library issues

Hey, So I am developing an Azureus plugin in NetBeans. I was using Eclipse and everything was hunky-dorry but for GUI related reasons I needed to switch to NetBeans The main class for my project is in an external JAR called Azerues2.jar. So I added the JAR it to the project's libraries. Then I go to the run configuration in order to se...